I have scheduled background service to change device home screen wallpaper periodically. The wallpaper changes successfully and they are perfectly set to the screen size. But when I move away from the home screen and return the image gets zoomed in too much,leaving only a portion of the image visible.Below given is the code I use
Bitmap theBitmap = null;
try {
DisplayMetrics metrics = new DisplayMetrics();
WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
windowManager.getDefaultDisplay().getMetrics(metrics);
int height = metrics.heightPixels;
int width = metrics.widthPixels;
theBitmap = Glide.with(mContext)
.load(PhotoPath)
.asBitmap().into(width, height).get();
WallpaperManager wm = WallpaperManager.getInstance(mContext);
wm.setWallpaperOffsetSteps(1, 1);
wm.suggestDesiredDimensions(width, height);
try {
wm.setBitmap(theBitmap);Album
} catch (IOException e) {
}
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
Try not to rush and flag this question as a duplicate. There are questions stating the image appears zoomed in when set but My wallpaper gets set perfectly,atleast initially it does. Why does it zoom in when I move homescreen to the background.

