Listen to own application uninstall event on Android-ThrowExceptions

Exception or error:

As far as I know, apps can’t get intents for their own uninstallation:

But how does Dolphin Browser manage to receive a “removed” event and start a browser as in the attached image?

enter image description here

        10-20 12:37:00.997: D/BackupManagerService(527): Received broadcast Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:mobi.mgeek.TunnyBrowser flg=0x8000010 (has extras) }
    10-20 12:37:00.997: V/BackupManagerService(527): removePackageParticipantsLocked: uid=10112 #1
    10-20 12:37:01.007: D/dalvikvm(527): GC_EXPLICIT freed 2247K, 12% free 20128K/22868K, paused 3ms+10ms, total 212ms
    10-20 12:37:01.107: D/dalvikvm(527): GC_FOR_ALLOC freed 1508K, 15% free 19649K/22868K, paused 60ms, total 60ms
    10-20 12:37:01.137: D/AndroidRuntime(4028): Calling main entry
    10-20 12:37:01.137: D/dalvikvm(4028): Note: class Landroid/app/ActivityManagerNative; has 163 unimplemented (abstract) methods
    10-20 12:37:01.147: I/ActivityManager(527): START u0 {act=android.intent.action.VIEW dat= 4&os=android&osv=4.3&cc=US&no=40471&lang=en&jk=uninstalled&ft=212&ht=957&ct=0&nt=1&res=768*1184&ifi=1&lts=1&iow=0&iom=0&iospd=0&iogs=0&debug=false&t=1382252820000 flg=0x10000000} from pid 4028
    10-20 12:37:01.157: D/AndroidRuntime(4028): Shutting down VM
How to solve:

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. 🙂


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 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.

Leave a Reply

Your email address will not be published. Required fields are marked *