问题
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)
回答1:
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.
回答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.
来源:https://stackoverflow.com/questions/7027187/uninstalling-apk-one-last-action-before-uninstall