user264953
user264953

Reputation: 1967

Android wallpaper issue

I am trying to set the wallpaper through an application with the following code:

        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();
            }
        }
    });

It works fine and the drawable image 'five' is being set as wallpaper on button click. But when I uninstall this APK which sets the wallpaper, I need to revert back to the default/previous wallpaper itself.

Why on deleting this APK, the wallpaper does not get reverted. What is the fix I have for this.

Any help is much appreciated.

Regards, Anees

Upvotes: 0

Views: 219

Answers (1)

chitacan
chitacan

Reputation: 341

That's because as soon as you set wallpaper via WallpaperManager, it converts requested image into a file and saves to system directory.(you can find its implementation here)

Well, I don't have any idea that reset default wallpaper when user uninstalling your app, I recommend you to put another button or find a way to get a default wallpaper.

Upvotes: 1

Related Questions