Detect if an app was uninstalled

前端 未结 4 1624
忘了有多久
忘了有多久 2021-01-17 15:34

Is there a way to get a system notification when an app has been uninstalled?

I would like to maintain a table of all clients\' info currently using my app. However

相关标签:
4条回答
  • 2021-01-17 16:13

    You could simply do it the other way round and maintain a table of users actively using your app. Just call a webservice at a point in the program that show it is active. If an app isn't used for a certain time mark it as inactive.

    0 讨论(0)
  • 2021-01-17 16:20

    Android doesn't provide an inbuilt function for tracking the app uninstall.

    Notification can be used as an alternate way to track the app uninstall. For this send notification on the app and track the status of the notification. Count the number of undelivered notification for a particular time period. If status of undelivered notification doesn't change in that particular time period, then consider that the app has been uninstalled from the device.

    For example, i have used a cron script which run every 3 days and check the status of last 10 notifications delivered to the device (2 notifications are sent in a day). If all of these 10 notifications have status "undelivered", then the app is considered to be uninstalled from the device.

    0 讨论(0)
  • 2021-01-17 16:29

    From Android document, the app uninstalled by user can't not get

    Intent.ACTION_PACKAGE_REMOVE
    

    But we can use other method to implement this feature. We all know that there is a directory named with your package name under the /data/data directory after your app installed by user. If your app is uninstalled by user, the root directory of your app(/data/data/com.example.yourappname) will be removed by system. The remove action happen immediately when user click "uninstall", and the directory will be removed by framework package manager system.

    So, we can monitor the existence of your app data directory(which usually /data/data/com.example.yourappname) to detect if your app uninstalled by user.

    In order to monitor this directory, we have to fork a detached process from JNI. In this new fork process, we can use Linux system api inotify(7) or access(3) to determine the existence of app's data directory.

    Here is a workable implementation. But it got the permission problem when try to send an intent to start system browser on high version Android device. I have no idea how to bypass this. However the example above is enough for your question.

    Hope it will be helpful!

    0 讨论(0)
  • 2021-01-17 16:33

    The documentation for the PACKAGE_REMOVED action says the following:

    The package that is being uninstalled does not receive this Intent.

    So you can monitor for other applications being uninstalled but not your own.

    So you'll probably need track who is still using your application, not who has stopped using it. If you don't want the overhead of having your own server to do this you could use a free service like Flurry.

    0 讨论(0)
提交回复
热议问题