Android - how to set the wallpaper image

James Cadd picture James Cadd · Dec 26, 2009 · Viewed 28.7k times · Source

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.

Answer

Kishore picture Kishore · Oct 18, 2012

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>