As far as I know, apps can\'t get intents for their own uninstallation:
But how doe
This is a security issue in Andorid, which is already reported to Google Team and fixed in Android 4.4. Here is my explanation of how it can work.
When the user go to app manager in phone setting, and click on your app, you receive a broadcast that contain your app name in extras, if the user click uninstall btn, the com.android.uninstaller.UnistallerActivity
must be launched.
If you get an intent and your app name in extras, that mean that the user clicked on your app in "app manager", use PackageManager
to start an activity watcher and get the top visible activity and his package, if the user click uninstall button you get UnistallerActivity
as top activity there you can popup a survey on the web browser or do what do you want do there.
Here is a way you can get uninstall event of your own app.
Using inotify
in native code.
For example: You can using inotify_add_watch
to monitor your application's data cache folder like: /data/data/your-package-name/cache
.
When your application gets uninstalled, you can get the folder's delete event.
Another key point is that inotify
should run in a seperate process from your own application.
You can invoke fork()
to do this.
I've already verified the logic. :)