views:

812

answers:

4

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.

+1  A: 

From this page on the developer site:

public void setStream (InputStream data)

Change the current system wallpaper to a specific byte stream. The give InputStream is copied into persistent storage and will now be used as the wallpaper. Currently it must be either a JPEG or PNG image.

ChrisF
Note that API first appeared in 2.0; if you want to support older versions, use one of the original APIs on Context:http://developer.android.com/reference/android/content/Context.html#setWallpaper(java.io.InputStream)
hackbod
A: 

hi, i am developing an application that does the same thing - download image from webserver and set it as wallpapers. Can you please share with me your code on how to do it or provide me some guidance as i am very new in android as well as java development. Thank you.

Lynnooi
+1  A: 

OK Here's how to do it:

You need to call getApplicationContext.setWallpaper() and pass it the bitmap. It just works! Yay!

Jonah
A: 

Can you please provide us with a sample code that sets a wallpaper . thanks a lot !

Amine