android - intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bmp) image is off center -


i having tad of issue when creating shortcuts on android desktop.

first, have 72x72 icon, load sd card bitmap object.

with bitmap object set icon resource.

the problem having when set it, image on shortcut appears off center , cut off. screen metrics size 72x72, not sure deal is.

code:

bitmap thebitmap = bitmapfactory.decodefile("/sdcard/icon.png"); intent.putextra(intent.extra_shortcut_icon, thebitmap) 

i've tried resizing , have got work utilizing canvas, drawable , bitmap, when restarting phone reverts small size.

using same icon drawable resource makes perfect, not dynamic:

parcelable iconresource = intent.shortcuticonresource.fromcontext(this, r.drawable.icon); intent.putextra(intent.extra_shortcut_icon_resource, iconresource); 

using samsung epic 4g w/ 2.1

i had similar issue. looked @ launcher source code , saw there's bug causes icon not appear correctly if initial bitmap size small.

scale bitmap 128x128 first:

bitmap scaledbitmap = bitmap.createscaledbitmap(thebitmap, 128, 128, true); intent.putextra(intent.extra_shortcut_icon, scaledbitmap); 

it'll fix it.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -