1. Demo description and demonstration
This Demo describes how to obtain the current Wallpaper in Android, modify Wallpaper, and then reset the Wallpaper with the modified image. Note that you must add the permission <uses-permission android in AndroidMainfest: name = "android. permission. SET_WALLPAPER "/>
The Demo is as follows:
2. Video description
3. Demo Analysis
SetWallpaper describes how to get the current Wallpaper in Android, modify the Wallpaper, and then reset the Wallpaper with the modified image.
WallpaperManager is used to manage Android Wallpaper. The following code uses WallpaperManager to obtain the current Wallpaper and display it on the imageView of the screen Layout.
Final WallpaperManager wallpaperManager
= WallpaperManager. getInstance (this );
Final Drawable wallpaperDrawable
= WallpaperManager. getDrawable ();
Final ImageView imageView
= (ImageView) findViewById (R. id. imageview );
ImageView. setDrawingCacheEnabled (true );
ImageView. setImageDrawable (wallpaperDrawable );
Reset Wallpaper through WallpaperManager.
WallpaperManager. setBitmap (imageView. getDrawingCache ());