I have use PhotoView and Glide libraries for my android project. The app is fetching images from a url and display them in a GridView. When the user clicks on a image it gets loaded into photoview which is inside a fragment of same activity.
Now i want to set that image as a wallpaper so I have written the following inside the button click listener:
WallpaperManager wallpaperManager = WallpaperManager.getInstance(getActivity());
bitmap = ((BitmapDrawable) photoView.getDrawable()).getBitmap();
try{
wallpaperManager.setBitmap(bitmap);
Toast.makeText(getActivity(), "wallpaper set", Toast.LENGTH_SHORT).show();
}catch(IOException e){
e.printStackTrace();
}
The error is in the following line:
bitmap = ((BitmapDrawable) photoView.getDrawable()).getBitmap();
Error is: Cannot cast TransitionDrawable into BitmapDrawable
How to cast it? or Is there any other way to set wallpaper?
all details in this link