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.
Great Answers, just one small thing left:
On every App update first ACTION_PACKAGE_REMOVED will be called followed by ACTION_PACKAGE_ADDED- if you wish to ignore these events, just add it on your onReceive():
This is from the docs:
In your manifest:
Add the line before the intent-filter tag
So your manifest should look like this:
Am not sure about the PACKAGE_REMOVED intent in that if its actually is available.
You must eliminate android.intent.action.PACKAGE_INSTALL as it is deprecated and no longer recommended, because it is just for the system. Everything else is perfect and I would recommend that instead of 100, put 999, the documentation does not give maximum or minimum number to use, the larger the number, the higher priority will have your receiver for that intent. Sorry for the translator. I speak and write in Spanish. Information