Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve hidensity drawable from package (honeycomb)

This code

final ApplicationInfo ai = getPackageManager().getApplicationInfo("com.company.hello", 0);
final Drawable d = getPackageManager().getApplicationIcon(ai);

retreive a 48x48 (mdpi) drawable even on my hidensity HoneyComb device.

Given that I can enlarge the drawable by Bitmap.createScaledBitmap, I'm asking how to extract the hi density icon that is already there. The method getDrawableForDensity is not available for sdk < 15, but I'm not happy to invoke a scaling function for each icon I've to draw when it is available in the package for free.

Edit for bounty

forgetting for a while my device display density the question is the following: given a own package for which we know for sure to have a 72x72 icon in the relative hdpi res folder, how to extract this icon from another package?

THIS FUNCTION is not available on Honeycomb environment.

like image 991
lorenzoff Avatar asked Jan 16 '13 14:01

lorenzoff


1 Answers

to find your drawable directlyy with the good density, you have just to try this :

mContext.getResources().getDrawable(R.drawable.mydrawable);

what is the problem? If android get you a 48x48 icon, it's that the good icon or, you haven't set icon in the good res/drawable- folder.

like image 101
throrin19 Avatar answered Nov 06 '22 17:11

throrin19