Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listen to own application uninstall event on Android

Tags:

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

  • ACTION_PACKAGE_FULLY_REMOVED
  • ACTION_PACKAGE_REMOVED

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

enter image description here

ADB:
        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 com.android.commands.am.Am
    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=http://survey.dolphin.com/int/uninstall?id=014f4d1981d6f88bb56630e7a3a7550a&pn=mobi.mgeek.TunnyBrowser&v=248&s=ofw&it=1382250136565&ut=1382250127000&m=Nexus 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 cmp=com.android.chrome/com.google.android.apps.chrome.Main} from pid 4028
    10-20 12:37:01.157: D/AndroidRuntime(4028): Shutting down VM
like image 350
NitZRobotKoder Avatar asked Oct 20 '13 09:10

NitZRobotKoder


People also ask

How can we handle the uninstall event of Android app?

How are App Uninstalls detected? You can detect app uninstalls by sending 'silent' push notifications. Silent push notifications are those notifications that aren't rendered on the user's device. You could send a silent push notification daily to all the devices with your app to track uninstalls.

How do I track uninstalled apps on Android?

Select the gear icon and go to Project Settings > Cloud Messaging. In your Singular account, go to Settings > Apps, find the app for which you want to track uninstalls, and select Edit. Under Uninstall Tracking, add the Project Number (Sender ID on Firebase) and Server Key.

How do I track uninstalled apps?

Open the Google Play app on your Android phone or tablet, and tap on the menu button (the three lines that show up in the upper left corner). When the menu is revealed, tap on "My apps & games." Next, tap on the "All" button, and that's it: you'll be able to check all your apps & games, both uninstalled, and installed.

Is it possible for an app to uninstall itself?

No you simply can't. At least not for the phones that are not rooted. You can take the user to an Uninstall screen, but they would have to click on "Uninstall" to uninstall the app. For more information visit install/uninstall application programmatically.


1 Answers

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

like image 102
aarontang Avatar answered Sep 27 '22 21:09

aarontang