How to make my app receive broadcast when other applications are installed or removed

android, broadcastreceiver, permissions

Solution

In your manifest:

<receiver android:name=".apps.AppListener">
    <intent-filter android:priority="100">
         <action android:name="android.intent.action.PACKAGE_INSTALL"/>
         <action android:name="android.intent.action.PACKAGE_ADDED"/>  
         <action android:name="android.intent.action.PACKAGE_REMOVED"/>
    </intent-filter>
</receiver>

Add the line before the intent-filter tag

<data android:scheme="package"/>

So your manifest should look like this:

<receiver android:name=".apps.AppListener">
    <intent-filter android:priority="100">
         <action android:name="android.intent.action.PACKAGE_INSTALL"/>
         <action android:name="android.intent.action.PACKAGE_ADDED"/>  
         <action android:name="android.intent.action.PACKAGE_REMOVED"/>
         <data android:scheme="package"/> 
    </intent-filter>
</receiver>

Am not sure about the PACKAGE_REMOVED intent in that if its actually is available.

Problem

I want to make an app that can receive broadcast when other apps on the device are installed or removed. my code in manifset: ``` <receiver android:name=".apps.AppListener"> <intent-filter android:priority="100"> <action android:name="android.intent.action.PACKAGE_INSTALL"/> <action android:name="android.intent.action.PACKAGE_ADDED"/> <action android:name="android.intent.action.PACKAGE_REMOVED"/> </intent-filter> </receiver> ``` in AppListener: ``` import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; public class AppListener extends BroadcastReceiver { @Override public void onReceive(Context context, Intent arg1) { // TODO Auto-generated method stub Log.v(TAG, "there is a broadcast"); } } ``` but I can't receive any broadcast. I think this problem is due to app permissions, any idea? Thanks for helps.

Original source