Setting An Image As A Wallpaper

This is a sample application to show that how to set an image as a Wallpaper.

Underlying Algorithm:

Basic description of algorithm in step by step form:
1.) Create a Project SetWallpaper.
2.) Add the relevant permissions to your AndroidManifest.xml file:

 

 

 

3.) Put some images in the res/drawable.
4.) Run the application.

Steps to Create:

1.) Open Eclipse. Use the New Project Wizard and select Android Project Give the respective project name i.e. SetWallpaper. Enter following information:
Project name: SetWallpaper
Build Target: Android 2.3
Application name: SetWallpaper
Package name: com.example.SetWallpaper
Create Activity: SetWallpaper

On Clicking Finish SetWallpaper code structure is generated with the necessary Android Packages being imported along with SetWallpaper.java. SetWallpaper class will look like following:

 

 

 

Output –The final output:

Leave a Comment:

18 comments
kevin says September 19, 2011

Hi nice guide.

I have a question if you can help, i followed the guide and when i run the apk in eclipse all i see it the heloo worls, setwallpaper! no button and no image.

i put my image in each drawable folder and have created a folder called drawable.

Im so new and could really use some help.

thanks

Reply
kevin says September 23, 2011

Hi great article,

I followed this and only get the hello world, setwallpaper! on the screen no button and no wallpaper.

I have added my wallpaper to each directory, now i know i need to add some code to tell the script to use my image. can you share what that code would be?

Thanks

Reply
kevin says October 11, 2011

Would be nice if you actually read some of the comments.
might as well of not had a comment section.

Reply
Balu says January 7, 2012

Can u please give a Full code to run in a eclipse..

Reply
nicedice says January 12, 2012

Hi,
Nice tut thanx – getting some errors in eclipse when amending the SetWallpaper.java:
Button buttonSetWallpaper = (Button)findViewById(R.id.set);
ImageView imagePreview = (ImageView)findViewById(R.id.preview);
imagePreview.setImageResource(R.drawable.five);

&
myWallpaperManager.setResource(R.drawable.five);

all throw errors!
any ideas?
thanks
D

Reply
nicedice says January 12, 2012

Hi,
Nice tut thanx – getting some errors in eclipse when amending the SetWallpaper.java:
Button buttonSetWallpaper = (Button)findViewById(R.id.set);
ImageView imagePreview = (ImageView)findViewById(R.id.preview);
imagePreview.setImageResource(R.drawable.five);

&
myWallpaperManager.setResource(R.drawable.five);

all throw errors!
any ideas?

thanks
D

Reply
srinivas says April 5, 2012

dear sir i’ve a doubt the above example gives only one image at a time which we explicitly add to imagePrieview.setImageResource(R.drawable.kiss);

so how can we write code for more than one image display as preview and select one and set as wall paper.

Reply
srinivas says April 5, 2012

dear sir i’ve a doubt the above example gives only one image at a time which we explicitly add to imagePrieview.setImageResource(R.drawable.kiss);

so how can we write code for more than one image display as preview and select one and set as wall paper.

Reply
kokesh says April 7, 2012

id cannot be resolved or is not a field at “Button buttonSetWallpaper = (” line + on few under) – I do have everything exactly as it is here. Any idea?

Reply
eldy says September 14, 2012

my image blur when set as background, can you explain more about the size..

Reply
edgarvikernes says December 21, 2012

Thanks friend it works perfectly :D!!

Reply
Suresh says January 30, 2013

Can you tell how to configure the size of the Wallpaper or configure the scaling of image after setting the wallpaper

Reply
sonu says August 6, 2013

he even did not know how to write for more than one images

Reply
sam says August 10, 2013

while i follow what you are doing here, it leaves out the basic example of using photo taken from with the camera to be set as wallpaper… i can certainly use your example to add resources and set the wallpaper from them, but this gives no idication whatsoever as to how to store an image to the resources from a startActivityForResults method then use the data received to set the wallpaper…

that is it gives no idication as to how to set a wallpaper from a previously unknown data set that the user may define…

Reply
Raj says August 20, 2013

sir , can you give me this code please …??
i want a zip file ..
can you please mail this code to me

Reply
caglar says September 11, 2013

This app makes zoom automatically.
How can I set the image as wallpaper without zoom?

Thank you for your time.

Reply
vishal says October 5, 2013

it was cool..it is perfectly running.but you showed only one image to set as wallpaper..can you tell how to add more images to set as wallpapers

Reply
Wallpaper Android Tutorial | Wallpapers says January 21, 2015

[…] Setting an image as a wallpaper | Android Programming … – This is a sample application to show that how to set an image as a Wallpaper. Underlying Algorithm: Basic description of algorithm in step by step form:… […]

Reply
Add Your Reply