Question

in my application i'm using WallpaperManager to set an image as a wallpaper for the device the problem is that when the application is uninstalled the image will stay, though it should be deleted i thought about this approach which is detecting when the applications is uninstalled and clear the image or cash but it doesn't seems to work, it seems the un-installation event cant be detected is there any other approach to solve it? or any tip to delete the photo after the un-installation of the application ?

Was it helpful?

Solution

Even if you delete the image from the internal/external memory, the image will be still set as the wallpaper because Android is keeping the relative bitmap in the volatile memory. You can use a BroadcastReceiver to capture the uninstall Intent:

http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REMOVED

But this will require you to install another application to listen for this Intent and then set a black background (or whatever you want) with

http://developer.android.com/reference/android/app/WallpaperManager.html#setBitmap%28android.graphics.Bitmap%29

Note: It may be possible that after you uninstall your app and the restart the phone, the image will not be set as wallpaper anymore. It all depends whether Android keeps his own copy of the image of the wallpaper or not...just test for it!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top