androiduninstallationdetectandroid-c2dm

Is it possible to detect Android app uninstall?


My app is using Google's C2DM (push notification) to notify users about new activity from friends. Once they install the app I register the device with C2DM servers and store user's phone number. So I know that the user is using my app and I can send him/her the push notifications. But what happens if users uninstalls my app, is there a way to catch it in my app? Or the only way is to catch an error on my server when I send a C2DM and it's unreachable, then mark a user as inactive?

I would love to notify users when their friends are using an app and when they no longer do.

What's is the best solution for this scenario?


Solution

  • Unfortunately the ACTION_PACKAGE_REMOVED intent will be sent out to all receivers except for your own. This is confirmed here.

    Some questions for your C2DM plan, since I'm not very familiar with it. If the user just leaves their device off for a long period of time, will that trigger the error condition you use? How does C2DM actually report an "unreachable" device? Is that a condition that only occurs when it attempts to send the push notification and fails or is it when it somehow determines it reaches the device but fails to be handled properly? Obviously in the second scenario your plan would work, but I can see some "false positives" occurring otherwise.

    Older SO question for reference: android not receiving Intent ACTION_PACKAGE_REMOVED in the removed package