user3090559
user3090559

Reputation: 1

I am making an app and want to know when the app is uninstalling

I am making an app and want to know when the app is uninstalling. For doing it, I used BroadcastReceiver but I don't know where is my code is wrong? (when my app is uninstalling, BroadcastReceiver can't receive any message about uninstalling) It's my app's Manifest:

<receiver android:name="receiver">
  <intent-filter>
     <action android:name="android.intent.action.PACKAGE_ADDED"/>
     <action android:name="android.intent.action.PACKAGE_DATA_CLEARED"/>
     <action android:name="android.intent.action.PACKAGE_INSTALL"/>
     <action android:name="android.intent.action.UID_REMOVED"/>    
     <action android:name="android.intent.action.PACKAGE_REMOVED"/>
     <action android:name="android.intent.action.MEDIA_REMOVED"/>
     <action android:name="android.intent.action.MEDIA_BAD_REMOVAL"/>  
     <action android:name="android.intent.action.BATTERY_OKAY"/>         
     <data android:scheme="com.example.testpermission"/>
  </intent-filter>

Upvotes: 0

Views: 167

Answers (2)

Gari BN
Gari BN

Reputation: 1685

You can't, but if you have second installed application on the device - you can get notification via that application about the uninstallation of the first one (as far as I remember).

I believe that the application cannot monitor its own uninstall from two reasons:

  1. It will make it much harder to uninstall application (some evil apps might even try to do something bad when their application is being removed).
  2. If you remove application - you cannot run it, or send it events! The app should be closed for clean deletion.

About how to do it from second app: Your second app should be a receiver to the ACTION_PACKAGE_REMOVED event (read about BroadcastReceiver, and see: http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REMOVED)

Upvotes: 0

Warpzit
Warpzit

Reputation: 28152

You cannot get an event when your own app is uninstalling. See here. There is also a post on the subject here.

Upvotes: 1

Related Questions