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 image
Display display = getWindowManager().getDefaultDisplay();
        screenSize = new Point();
display.getSize(screenSize);
new LoadImageTask(screenSize.x, screenSize.y, this).execute();

...

// In the response listener
WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
Point desiredSize = new Point(
        wallpaperManager.getDesiredMinimumWidth(),
        wallpaperManager.getDesiredMinimumHeight());

Bitmap wallpaper = Bitmap.createBitmap(desiredSize.x, desiredSize.y, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(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"