When something is out of date, it means that the developers have created a better way to do this and that you should no longer use the old or obsolete method. Items that are out of date are subject to disposal in the future.
In your case, the correct way to set the wallpaper, if you have a path to the image, is as follows:
is = new FileInputStream(new File(imagePath)); bis = new BufferedInputStream(is); Bitmap bitmap = BitmapFactory.decodeStream(bis); Bitmap useThisBitmap = Bitmap.createScaledBitmap( bitmap, parent.getWidth(), parent.getHeight(), true); bitmap.recycle(); if(imagePath!=null){ System.out.println("Hi I am try to open Bit map"); wallpaperManager = WallpaperManager.getInstance(this); wallpaperDrawable = wallpaperManager.getDrawable(); wallpaperManager.setBitmap(useThisBitmap);
If you have an image URI, use the following:
wallpaperManager = WallpaperManager.getInstance(this); wallpaperDrawable = wallpaperManager.getDrawable(); mImageView.setImageURI(imagepath);
From Maidul, answer this question.
source share