I am having a tad of an issue when creating shortcuts on my android desktop.
First, I have a 72×72 icon, I load it from my SD card into a Bitmap object.
With that bitmap object I set it as my icon resource.
The problem I am having is when I set it, the image on the shortcut appears off center and cut off. From the screen metrics I get the size as 72×72, not sure what the deal is.
Code:
Bitmap theBitmap = BitmapFactory.decodeFile("/sdcard/icon.png");
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, theBitmap)
I’ve tried resizing it and have got it to work utilizing a canvas, drawable and another bitmap, however when restarting the phone it reverts to a small size.
Using the very same icon as a drawable resource makes it look perfect, but its not dynamic:
Parcelable iconResource = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
Using a Samsung Epic 4g w/ 2.1
I had a similar issue. I looked at the Launcher source code and I saw that there’s a bug that causes the icon not to appear correctly if the initial bitmap size is too small.
Scale the bitmap to 128×128 first:
It’ll fix it.