Skip to content Skip to sidebar Skip to footer

Center Android Wallpaper

I'm trying to make an app that changes the system wallpaper. In my code I get an image that has the desired minimum dimensions (from WallpaperManager). For example on the Nexus One

Solution 1:

Have you tried to switch between virtual home screens? Aren't you at the leftmost virtual home screen?

Solution 2:

MY SOLUTION

In the end I got the image in the screen size (480x800 for the Nexus One) and then copied it into a bitmap that was the desired dimensions (884x800 for the Nexus One).

//Getting the imageDisplaydisplay= getWindowManager().getDefaultDisplay();
        screenSize = newPoint();
display.getSize(screenSize);
newLoadImageTask(screenSize.x, screenSize.y, this).execute();

...

// In the response listenerWallpaperManagerwallpaperManager= WallpaperManager.getInstance(this);
PointdesiredSize=newPoint(
        wallpaperManager.getDesiredMinimumWidth(),
        wallpaperManager.getDesiredMinimumHeight());

Bitmapwallpaper= Bitmap.createBitmap(desiredSize.x, desiredSize.y, Bitmap.Config.ARGB_8888);
Canvascanvas=newCanvas(wallpaper);
canvas.drawBitmap(bitmap, 0, 0, null);

try {
    wallpaperManager.setBitmap(wallpaper);
} catch (IOException e) {
    Log.e("Error", e.toString());
}

And it works on all virtual screens

Post a Comment for "Center Android Wallpaper"