2

I added an activity with an intent filter to intercept the uninstall of my app so I can add some additional processing/cleanup when a user uninstalls my app. My activity get called just fine but I seem unable to complete the removal of the package from the device.

<activity
        android:name=".Uninstall"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.DELETE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="package"  />
        </intent-filter>
    </activity>

When I use the package manager to try to complete the uninstall it just pops up the same chooser dialog.

Intent intent = new Intent(Intent.ACTION_DELETE, Uri.fromParts("package", Uninstall.this.getPackageName(), null));
startActivity(intent);

If I am providing an alternative uninstall activity for my app how do I complete the actual uninstall of the apk from the device?

Thanks.

Kazekage Gaara
  • 14,972
  • 14
  • 61
  • 108
  • The application `NQ Mobile Security` is calling an `Activity` at uninstall look at the (http://imgur.com/Fos9N), (http://imgur.com/fIZbK) and (http://imgur.com/cG9Hr) and the question http://stackoverflow.com/questions/10219328/how-to-show-an-activity-before-my-app-is-uninstalled-android – Gaurav Agarwal Jun 16 '12 at 09:40

1 Answers1

2

You should take a look at the reference documentation for your intents. The intent ACTION_DELETE has to do with the deletion of items from a container, and not of applications/packages. The intent that handles the removal of applications/packages is ACTION_PACKAGE_REMOVED but as the documentation states:

An existing application package has been removed from the device. The data contains the name of the package. The package that is being (un)installed does not receive this Intent.

So the short answer to your question is that it cannot be done. If you play by the book, you don't need to perform additional tasks at uninstall time.

K-ballo
  • 80,396
  • 20
  • 159
  • 169
  • thank you for your response. I do want to play by the book, but I also would like to handle the uninstall of my app so I can clean up data on my server and stop sending push notifications proactively. – Mark Nuetzmann Jun 12 '12 at 18:41
  • @Mark Nuetzmann: Oh, that would be nice. However AFAIK there is no way to do it, short of having a second application listening to packages removed. – K-ballo Jun 12 '12 at 18:44
  • @K-ballo The application `NQ Mobile Security` is calling an Activity at uninstall look at the http://i.imgur.com/Fos9N.png, http://i.imgur.com/fIZbK.png, http://i.imgur.com/cG9Hr.png and the question http://stackoverflow.com/questions/10219328/how-to-show-an-activity-before-my-app-is-uninstalled-android – Gaurav Agarwal Jun 16 '12 at 09:41