Have a number of image files resources e.g. image01.png, image02.png....
I have have set up resource folders with different locale/resolution/orientation qualifiers e.g.
/res/drawable-en-mdpi-port
/res/drawable-en-mdpi-land
/res/drawable-fr-hdpi-port...........
Image files in each differ (aspect ratio/resolution/locale-specfic image)
Is there anyway to programatically determine which actual resource file is in use in application? Would be useful to me for testing to send it out on debug log, so can be sure correct image file is being used i.e. I have set-up resource qualifiers correctly and placed correct images in correct folders.
Can do this manually, but as number of images increases this becomes a major chore.
I am guessing from similar questions about determining resource paths that this may not be possible. If not, does anyone have any tricks/tips? I could add an ID text to image (maybe even use a script to batch watermark images with filename) but would be happy to hear if there is a simpler way.
If you wonder what PNG file that is currently (with the current configuration) loaded for, say
R.drawable.icon
, you can do this:on an hdpi device, the output will be:
This will give you the path to the actual resources used independently of how complex the path is. It only works for resources that are individual files within your .apk though, most notably drawables.
Usually resource files will be automatically selected if u follow the android folder naming conventions in your app else you can get the resolution of the screen, height of the screen and width of the screen so on in the activity using the below APIs.
U can do it using this but it works only if u follow the android folder naming conventions