How to get the hdpi application icon on Android API 11 or more tablets (in java code)?

I noticed on Motorola xoom that the app icons on Launcher are 72px at 72px. This is usually the size of the icons defined in drawable-hdpi / in packages.

In my application, I want to display the icons of some installed applications at 72x72px. Currently, I get icons for installed applications through the PackageManager, but it returns me bitmaps with a smaller size (46 pixels), which corresponds to the resources defined in drawable-mdpi / for each package. This is unacceptable to me, as I would like to display these icons in a larger format.

Apparently the Motorola xoom's 10-inch screen is 160dpi, thus mdpi and xlarge (see http://developer.android.com/guide/practices/screens_support.html#range ). This explains the behavior of the PackageManager returning mdpi resouces instead of hdpi resources.

How can I get the icons of installed applications at least 72x72px in size? Does anyone know how this was done in the Launcher Android Honeycomb app?

Thanks Laurent

+4
source share
1 answer

You can create a special subfolder in the res folder and name it as drawable-large-v11 , or drawable-large-v11, or another name suitable for your application.

Then copy the large icon to this subfolder, but the file name should be the same as in other folders for different dpi. I used this approach in my applications and it works great.

+2
source

All Articles