Note: Please don't mark it as duplicate as the same question is asked years back, which might have worked then, but not working now.
using below code my wallpaper is either stretching to screen 2 and 3 or getting cropped at the bottom of the screen based on the device. The below code is working on Samsung devices but not on other manufacturers devices.
I also tried using using the following methods for getting height and width, which didnt work(Wallpaper zoomed and stretched to other screens). getWallpaperDesiredMinimumHeight() and getWallpaperDesiredMinimumWidth()
public void setWallpaper() {
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int height = displayMetrics.heightPixels;
int width = displayMetrics.widthPixels;
WallpaperManager wm = WallpaperManager.getInstance(this);
Bitmap bmap = BitmapFactory.decodeResource(getResources(), R.drawable.myPicture);
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bmap, width, height, true);
wm.setWallpaperOffsetSteps(1, 1);
wm.suggestDesiredDimensions(width, height);
try {
wm.setBitmap(scaledBitmap);
} catch (IOException e) {
}
}