Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - how to set the wallpaper image

Is it possible to set the android wallpaper image programatically? I'd like to create a service that downloads an image from the web and updates the home screen wallpaper periodically.

like image 240
James Cadd Avatar asked Dec 26 '09 19:12

James Cadd


People also ask

How do you set an image as a wallpaper?

Choose a background wallpaperRight-click your desktop. Select Set wallpaper & style. Select Wallpaper. Select one of the images to set as your wallpaper.


1 Answers

If you have image URL then use

WallpaperManager wpm = WallpaperManager.getInstance(context); InputStream ins = new URL("absolute/path/of/image").openStream(); wpm.setStream(ins); 

If you have image URI then use

WallpaperManager wpm = WallpaperManager.getInstance(context); wpm.setResource(Uri.of.image); 

In your manifest file:

<uses-permission android:name="android.permission.SET_WALLPAPER"></uses-permission> 
like image 130
Kishore Avatar answered Oct 26 '22 19:10

Kishore