I have been using this code for a while now but it is not working as expected it sets the wallpaper bigger than the screen making it bigger so I scaled to so it would fit the screen and it worked fine but the thing is that when I restart the device the scaling disappears making the wallpaper bigger than the screen again so I used broadcast receiver to fix this but it works for some devices and not all of them.
(the image gets bigger in width and height so when the user scrolls between the pages the next part of the image scrolls with him -see image below for more details- )
here is my final code:
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int height = metrics.heightPixels;
int width = metrics.widthPixels;
Bitmap tempbitMap = BitmapFactory.decodeResource(getResources(), tophone);
Bitmap bitmap = Bitmap.createScaledBitmap(tempbitMap,width,height, true);
WallpaperManager wallpaperManager = WallpaperManager.getInstance(MainActivity.this);
wallpaperManager.setWallpaperOffsetSteps(1, 1);
wallpaperManager.suggestDesiredDimensions(width, height);
try {
wallpaperManager.setBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
can anyone tell me another code than this one that makes the wallpaper fit the screen without scaling it and without needing to use broadcast receiver Thank you!!