Setting An Image As A Wallpaper

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:

Comments 18

  1. 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

  2. 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

  3. 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

  4. 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

  5. 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.

  6. 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.

  7. 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?

  8. 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…

  9. 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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">