5

So I was developing wallpaper changer long time ago and got it released. After a while I started receiving comment the wallpaper not resizing correctly. Also I tried on different sizes of emus and they were right. I scale the bitmap correctly etc. but somehow android tends to rescale the wallpaper even bigger! Is there way to avoid that? My code:

Display display = parent.getWindowManager().getDefaultDisplay(); 
                    int width = display.getWidth();
                    int height = display.getHeight();
                    Bitmap scaled = Bitmap.createScaledBitmap(wallpaper, width, height, true);
                WallpaperManager wm = WallpaperManager.getInstance(getContext());
                wm.setBitmap(scaled);

I've been trying other ways too but nothing seems help, even if I afterwards check if the rescaled wallpaper is right size etc. :( Any ideas?

Ruuhkis
  • 1,924
  • 1
  • 27
  • 46
  • I remember reading something about the wallpaper manager trying to resize images automatically a while back...You might want to look around for articles about that. – Max Jan 16 '12 at 20:58
  • See this post: http://stackoverflow.com/questions/2010399/android-wallpaper-background-dimensions for info on the proper dimensions for wallpaper. – kabuko Jan 16 '12 at 21:22
  • I've got proper site but as Max stated " wallpaper manager trying to resize images automatically" And the question is, can I avoid that? – Ruuhkis Jan 17 '12 at 18:13

3 Answers3

0

I had the same problem, after resize wallpaper had the same size, but diffrent resolution.

In my case that code solved problem:

DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);

        int height = metrics.heightPixels;
        int width = metrics.widthPixels;

        Bitmap bitmap = Bitmap
                .createScaledBitmap(whatever, width, height, true);
Tomi89
  • 41
  • 1
  • 1
  • 3
0

I had to create overlay image.

  1. Create a blank image with size of WallpaperManager.getDesiredMinimumWidth() x WallpaperManager.getDesiredMinimumHeight()

  2. Resize your bitmap to screen size with, Display display = getWindowManager().getDefaultDisplay(); bmp = Bitmap.createScaledBitmap(bmp, display.getWidth(), display.getHeight(), false);

  3. Overlay your wallpaper on center of blank image. And set Overlay as wallpaper.

Max
  • 1,528
  • 21
  • 33
0

I suppose you could resize the wallpapers using the size specified by WallpaperManager.getDesiredMinimumWidth() and WallpaperManager.getDesiredMinimumHeight(), instead of the display size. That way, even the requirements set by custom home applications (like those possibly set by device manufacturers and/or service providers) will be respected, meaning a (much) larger compatibility for your app.

XMoby
  • 171
  • 4