0

i am creating a simple app for a project that comes with an image and above it a button when you press the button the image becomes the wallpaper of the phone.

This i have done however for my project i need the wallpaper to be removed if the app is uninstalled how do i do this?

Dhaval Parmar
  • 18,812
  • 8
  • 82
  • 177
  • The post title and the contents are two different things. Which one is the actual question? Remove all images or change the Wallpaper. And what have you tried to do so far? – Siddharth Lele Apr 08 '13 at 12:31
  • well if you remove the image that comes with the app surely the wallpaper will go away when its uninstalled no? – user2211271 Apr 08 '13 at 12:34
  • I don't think it possible, as far as I know the wallpaper will persist even if the image was removed from file system until reboot or SystemUI or Launcher (?) restart. There is nothing I know you can do about it. – Yaroslav Mytkalyk Apr 08 '13 at 12:37
  • 2
    @user2211271: Actually, no! Once an image has been set as a wallpaper, it doesn't matter if the original image remains on the device or not. The current wallpaper is **stored** in the **system partition.**. [Source](http://android.stackexchange.com/questions/27692/where-is-current-wallpaper-stored-on-jellybean). But don't take my word for it. Set any image as a wallpaper, then delete the image and restart your device just to check and confirm. – Siddharth Lele Apr 08 '13 at 12:41
  • ok so how do i get the wallpaper image to go away once uninstalled i must have to do something with the code/manifest? – user2211271 Apr 08 '13 at 12:51

2 Answers2

1

Save your images here this folder will be deleted when you uninstall the app

Arun C
  • 9,035
  • 2
  • 28
  • 42
0

If you look at the Android Documentation for the Intent ACTION_PACKAGE_REMOVED, you will see that this broadcast action will be received by any other interested application (other apps who are registered to receive this broadcast), other than your own application.

Quote from the developer.android.com site:

Broadcast Action: An existing application package has been removed from the device. The data contains the name of the package. The package that is being installed does not receive this Intent.

Unfortunetaly, because your app can never detect that it is being removed, you cannot trigger a specific function that will change the Wallpaper on the device. If it were possible (which it isn't), a simple function (code follows) would have shown the Select Wallpaper chooser to the user.

Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
startActivity(Intent.createChooser(intent, "Select Wallpaper"));

It is something the user will have to manually change once he / she has uninstalled your application.

That being said, as far as deleting all your app created files are concerned, let Android handle that for you. Use one of these options depending on the API:

API greater 8 or greater: getExternalCacheDir

API 7 or lesser: getExternalStorageDirectory.

Something like this will let you determine which one to use depending on the device API:

int currentAPIVersion = android.os.Build.VERSION.SDK_INT;
if (currentAPIVersion >= android.os.Build.VERSION_CODES.ECLAIR) {
    // USE getExternalStorageDirectory
} else {
    // USE getExternalCacheDir
}
Siddharth Lele
  • 27,623
  • 15
  • 98
  • 151