[Solved] Not Set Wallpaper in My Home Screen Android


You have to set permission in manifest file like this:

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

Use the below code for set background:

Button buttonSetWallpaper = (Button)findViewById(R.id.set);
ImageView imagePreview = (ImageView)findViewById(R.id.preview);
imagePreview.setImageResource(R.drawable.five);

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

solved Not Set Wallpaper in My Home Screen Android