THIS IS MY CODE IN WHICH I WANT TO SET THE IMAGE IN selectedimgeView AS THE WALLPAPEREI have created an app with gallery view in which when we click on the image in gallery view it opens in an image view above it. But now I want that selected image to set as the phone wallpaper. Can anyone help me with it. Please help anyone.
Asked
Active
Viewed 120 times
0
-
This has already been answered here: https://stackoverflow.com/questions/20053919/programmatically-set-android-phones-background – fhossfel Jul 13 '17 at 18:59
2 Answers
0
First you will need to add the set wallpaper permission in your manifest.
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
Once thats there you can use something along the lines of this:
WallpaperManager myWallpaperManager
= WallpaperManager.getInstance(getApplicationContext());
try {
myWallpaperManager.setResource(R.drawable.five);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Where the myWallpaperManager.setResource can also be myWallpaperManager.setBitmap etc.

Devsil
- 598
- 3
- 16
0
You need to use wallpaper manager ,with wallpaper manager you can use your image with desired size.
this tutorial might probably help you http://www.androidbegin.com/tutorial/set-an-image-as-wallpaper-in-android/

Mona Vafa
- 73
- 1
- 7