Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting wallpaper in Android

I am developing a simple app that sets wallpapers based on user input. I am missing code for setting wallpapers. I have been looking for it in lots of websites in vain. Can anybody post a sample code that sets as a wallpaper as a drawable that is saved in the res folder?

like image 424
Amine Avatar asked Aug 03 '10 18:08

Amine


People also ask

How do I set different wallpapers on Android home screen?

If you use Go Launcher EX, you can tap and hold down the middle of the home screen, and you should get a menu bar on the bottom. Choose Wallpaper. From here, choose the icon for Go Multiple Wallpaper. On the next screen, choose one image for each home screen.

How can I set full wallpaper on my mobile screen?

Tip: touch and hold the empty space on your home screen and select Wallpaper at the bottom to reach the wallpaper setting screen. Pick the image you want to use as your background. Once your image (portrait or landscape) is selected, you will see a preview of your wallpaper filling up your whole screen.


1 Answers

Works on Android 1.5 and above

public void setWallpaper() {
  Context context = this.getBaseContext(); 
  Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), mImageIds[pos]);

  context.setWallpaper(mBitmap);
}
like image 110
success_anil Avatar answered Oct 04 '22 01:10

success_anil