tags:

views:

24

answers:

0

Does anyone know of a way to tell which folder Android system will resolve to when I request a particular drawable from the Resources (drawable-long vs. drawable-notlong, for example)? I want to make sure it's loading resources the way I would expect it to (for instance, to make sure the Tattoo is really ldpi and not mdpi since it's right on the borderline).

I could always print out the intrinsic size of the drawable after I fetch it from Resources, and check that against the various image sizes I have, but that's kind of a pain. Plus, my company allows its clients to skin their app before it's released, so after it's been skinned I won't be able to rely on that method.

I tried using Resources.getName(resId) but that doesn't give the folder name, and as far as I know you can get a AssetFileDescriptor for the resource but you can't get an actual filename.

UPDATE: Since asking this question I have discovered that you can access many of the resource qualifier names through the Configuration and DisplayMetrics classes (both accessible via getResources()). DisplayMetrics can give you the ldpi/mdpi/hdpi designation, and Configuration can give you small/normal/large screen size, long/notlong aspect ratio, locale, mobile network codes, and other hardware information. However, this still does not positively confirm that you are getting the resources you expect if you have a complicated resource set. It also does not protect you from bugs that report the incorrect values, like the Motorola Droid bug where the DisplayMetrics reports the wrong xdpi and ydpi (it reports 96dpi where the real value is more like 265dpi! Terrible bug.).