I have one set of images in one drawable folder. I have one button to set image as wallpaper on device screen. But when I set this image as wallpaper its either zoom or crop
Try this code:
public void changeWallpaper(String path) {
FileInputStream is;
BufferedInputStream bis;
WallpaperManager wallpaperManager;
Drawable wallpaperDrawable;
File sdcard = Environment.getExternalStorageDirectory();
try {
is = new FileInputStream(new File(path));
bis = new BufferedInputStream(is);
Bitmap bitmap = BitmapFactory.decodeStream(bis);
Bitmap useThisBitmap = Bitmap.createBitmap(bitmap);
wallpaperManager = WallpaperManager.getInstance(getActivity());
wallpaperDrawable = wallpaperManager.getDrawable();
wallpaperManager.setBitmap(useThisBitmap);
} catch (Exception e) {
e.printStackTrace();
}
}
In this example , I have used image from my device SD card...
It's perfectly worked for me..