I have problems to find out the correct launcher icon size for my shortcut.
On my Nexus 7.2 the value of android.R.dimen.app_icon_size (see code) is 96 pixels. But if I
I have found out a working solution:
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private int launcherLargeIconSize() {
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
return activityManager.getLauncherLargeIconSize();
}
int size1 = (int) getResources().getDimension(android.R.dimen.app_icon_size);
int size2 = Build.VERSION.SDK_INT >= 11 ? launcherLargeIconSize() : 0;
int size = size2 > size1 ? size2 : size1;
If you notice in the android res folder - there should be several drawable folders
drawable hdpi , drawable mdpi, drawable ldpi and so on each folder has designated images for each device, because each device shows images according to screen density, some devices have low density, and some have high density
which is why on one device your icon size is 96 px, and on another it is 72
the older and smaller devices are even 48 and 36
in order to fix the problem, you just have to populate the appropriate drawable folders, with the right size icon file, and then you wont have a problem
for more info, read this : Supporting multi screens in android
Getting the right size of a launcher icon seems to be not as straight forward as one might expect. I know that at least tablets go one folder up in the drawables folder to show larger icons then expected by the screen density.
Here is this a bit more discussed