Search code examples
androidbitmapscalecenterwallpaper

Android WallpaperManager scales Bitmap too small


the WallpaperManager scales the wallpaper too small on some devices. I used the following code.

    Bitmap srcBitmap = .....
    WallpaperManager wm = WallpaperManager
                .getInstance(getApplicationContext());
    int height = wm.getDesiredMinimumHeight();
    int width = wm.getDesiredMinimumWidth();
    wm.setBitmap(Bitmap.createScaledBitmap(srcBitmap, width , height , true);

On the galaxy note with android 4.0.4 the wallpaper fills the full screen. But on galaxy s2 with 2.3 the wallpaper fills only a small rectangle in the center of the screen.

greetings,

mp5


Solution

  • the problem was that wm.getDesiredMinimumHeight(); and wm.getDesiredMinimumWidth(); return -1 on some devices. So Bitmap.createScaledBitmap(srcBitmap, width , height , true); failed and the original size of srcBitmap was used.