When you use Intent.ACTION_DELETE, how can you tell if the user actually uninstalls the app?

android, android-package-managers, uninstallation

Solution

You have two options, and you might want to use a combination of the two:

1) Register a `BroadcastReceiver` for `ACTION_PACKAGE_REMOVED`, and once fired, you can inspect the `data` of the intent to see whether your package was removed. It might be wise to add a time-out of sorts, possibly through an Alarm set five minutes into the future.

2) Once the user returns from either uninstalling or canceling the uninstall, your Activity will resume. You can check whether the package of interest still exists in `onResume()`, using `PackageManager.getPackageInfo()` or similar. Note: The user might not return to your app, in which case the time-out/Alarm recommendation would become important.

Problem

This is my code ``` Intent intent = new Intent(Intent.ACTION_DELETE); intent.setData(Uri.parse("package:" + theApp.getAppOpen())); startActivity(intent); ``` When startActivity is called, a default prompt comes up, asking the user whether they want to uninstall that app. How can I tell if the user says "ok" to uninstall the app? Assume my app is not the one being uninstalled.

Original source

Related problems