1. Call the system's Intent.ACTION_ATTACH_DATA. This Intent will evoke all the wallpaper program and the contact avatar program. Users can choose through ChooseActivity:
This Intent is a standard Intent, so all settings will be supported
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA); (Intent.FLAG_GRANT_READ_URI_PERMISSION); ("mimeType", "image/*"); Uri uri = ( .insertImage(getActivity().getContentResolver(), ((BitmapDrawable) wallpaper).getBitmap(), null, null)); (uri); startActivityForResult(intent, SET_WALLPAPER);
2. Set up through WallpaperManager
This method can directly place the picture as a wallpaper, which is used for Android systems on all platforms, but it is impossible to crop/adjust the picture.
try { WallpaperManager wpm = (WallpaperManager) getActivity().getSystemService( Context.WALLPAPER_SERVICE); if (wallpaper != null) { (bitmap); ("xzy", "wallpaper not null"); } } catch (IOException e) { (TAG, "Failed to set wallpaper: " + e); }
Authorization required:
<uses-permission android:name = ".SET_WALLPAPER"/>
The above operation method for setting up wallpaper on Android is all the content I share with you. I hope you can give you a reference and I hope you can support me more.