Phate Phate - 1 year ago 129
Android Question

Programmatically set android phone's background

I'd like to allow the user to choose a background from a list of images, the user clicks on one of them and that image is used as background for his phone.
My app should simply be another version of the android default gallery.

Is it possible to programmatically set the phone's wallpaper?

Answer Source

First one, you need set the permission in your Manifest.xml file

 <uses-permission android:name="android.permission.SET_WALLPAPER"/>

And you can set the background with this:

Button buttonSetWallpaper = (Button)findViewById(;
            ImageView imagePreview = (ImageView)findViewById(;

            buttonSetWallpaper.setOnClickListener(new Button.OnClickListener(){
            public void onClick(View arg0) {
            // TODO Auto-generated method stub
            WallpaperManager myWallpaperManager 
            = WallpaperManager.getInstance(getApplicationContext());
            try {
            } catch (IOException e) {
                // TODO Auto-generated catch block

That works

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download