Reputation: 37
I'm using the Android notification system. This system save an id for all devices for which notification will be sent. When any user uninstall the APP and the attempts to send one notification throws an error.
Can I code any method when the user unistall the app? Android has a method that runs on the app when it is uninstalled?
Upvotes: 0
Views: 180
Reputation: 75619
No. your app will not get any notification while being uninstalled. There's ACTION_PACKAGE_REMOVED
broadcast, but your app will not get it as it is being broadcasted once the package is removed, so your app is already gone at that time. Docs read (here):
Broadcast Action: An existing application package has been removed from the device. The data contains the name of the package. The package that is being installed does not receive this Intent.
Upvotes: 2
Reputation: 1909
while an app is uninstalled ACTION_PACKAGE_REMOVED
intent will be sent to all receivers except the currently uninstalled app so by another app you can know that.
Upvotes: 0
Reputation: 295
Your code is inside your app, not outside to send any notification at a time of uninstalling it. Outsider coding is done by Android OS so leave it to him.
Upvotes: -1
Reputation: 5149
There is no way for an app to tell if it has been uninstalled or to receive notification of it's pending uninstallation.
When an application is removed, the ACTION_PACKAGE_REMOVED
intent will be sent out to all receivers except for your own. Read the docs for more.
Upvotes: 1
Reputation: 1215
There is no callback that you will get when your app get uninstalled.
Upvotes: 0