BroadcastReceiver for new applications

I want to be notified when a new application is installed.

IntentFilter newAppFilter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
newAppFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
newAppFilter.addAction(Intent.ACTION_PACKAGE_INSTALL);
newAppFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
getApplicationContext().registerReceiver(newAppReceiver, newAppFilter);


public static BroadcastReceiver newAppReceiver = new BroadcastReceiver() {
    public void onReceive(Context context, Intent intent) {     
            Log.e("Broadcast","Received");
       }
};

But I can not get any magazine. Can anybody help me?

+3
source share
2 answers

Try adding a data schema to yours IntentFilter.

newAppFilter.addDataScheme("package");

Link: IntentFilter.addDataScheme () documentation

If the schemes are not included, then the Intent will be consistent only if it includes no data.

+9
source

If someone comes across this, the intent documentation now says:
ACTION_PACKAGE_INSTALL - this constant is deprecated. This constant has never been used.

+2
source

All Articles