Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't receive broadcasts for PACKAGE intents

Tags:

android

I am trying to register a Broadcast Receiver to receive broadcast events for the package events. Following is the code and my receiver in the manifest file. The log statment never happens, but I can clearly see the same broadcast firing for "HomeLoaders" (the Launcher) debug statements. What am I missing?

public class IntentListener extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        Log.i("INTENT LISTNER:", intent.getAction());
    }
}

<receiver android:name="IntentListener" android:enabled="true" android:exported="true">
    <intent-filter>
        <data android:scheme="package"></data>
        <action android:name="android.intent.action.PACKAGE_ADDED"></action>
        <action android:name="android.intent.action.PACKAGE_ADDED"></action>
        <action android:name="android.intent.action.PACKAGE_CHANGED"></action>
    </intent-filter>
</receiver>
like image 406
James Avatar asked Oct 15 '22 13:10

James


1 Answers

It is possible that these Intents cannot be received by components registered in the manifest, but only by receivers registered in Java via registerReceiver().

like image 174
CommonsWare Avatar answered Oct 18 '22 23:10

CommonsWare