7

I'm developing an application for Android that installs stuff on the phone's sim card. What I wan't is for the application to do one last action upon uninstall : remove what's inside the sim card. Which means : I need to do one last action when my APK is uninstalled.

Problem : I didn't find any way to do so. (Apart from having a secondary application, that catches the uninstall intent, and does the job, but that's very faaaaar from what I wan't I'm afraid)

If anyone has a solution, I'm really interested.

Thanks in advance.

(PS : I'm kind of afraid that there is none, actually)

Redwarp
  • 3,221
  • 3
  • 31
  • 44
  • See also http://stackoverflow.com/questions/2874412/get-application-uninstall-event-in-android – Joubarc Aug 11 '11 at 14:24
  • 1
    +! for thinking of clearing the SD card for the user – ahodder Aug 11 '11 at 14:45
  • SD card is actually cleaned up by Android, if correct paths are used. See http://developer.android.com/reference/android/content/Context.html#getExternalFilesDir%28java.lang.String%29 – inazaruk Aug 11 '11 at 16:00
  • I'm not talking about SD Card, but SIM Card... It's a bit different ^^ – Redwarp Apr 13 '12 at 09:25

2 Answers2

7

You are correct. There is no such event, and there is no supported way to get notified when your application is being uninstalled. Application's process is simply killed (if it was running) and application is uninstalled.

inazaruk
  • 74,247
  • 24
  • 188
  • 156
  • That's sad, in a way, it would be nice to have special intents sent to the application when it's uninstalled (and maybe when it's installed). Has there been a request made for that? Or is there any foreseeable danger in doing it? – Joubarc Aug 11 '11 at 14:20
  • 1
    You can detect when other applications are installed or unisntalled via `ACTION_PACKAGE_ADDED`/`ACTION_PACKAGE_REMOVED` broadcasts (see Intent doc page). You also can detect when your application is started for the first time (using `SharedPreferences` for example). I don't think there is such feature request for "I am being uninstall event", and even if it was requested I really doubt it will be satisfied. – inazaruk Aug 11 '11 at 14:38
  • Well, that pretty much replies to my questions. Thanks to all. I guess it's to much of a security hazard. – Redwarp Aug 11 '11 at 15:57
2

If you can detect if other applications are uninstalled via ACTION_PACKAGE_REMOVED, wouldn't is be possible to solve the problem if you made 2 applications? The second being a broadcastreceiver that catches the intent and then deletes content.

kristof01
  • 113
  • 1
  • 6