Skip to content Skip to sidebar Skip to footer

Is It Possible That Two Broadcastreceiver From Two Apps, Based On The Same Broadcast Intent Action, Somehow "collide"?

I have a BroadcastReceiver inside a service: public class NotificationClickService extends Service { private static final String DEBUG_TAG = 'NotificationClickService'; @

Solution 1:

While I'm still having trouble deciphering your question, I can't see how your receiver would have ever been called. You are missing the category registration in your intent filter.

Try:

IntentFilter filter = new IntentFilter(DownloadManager.ACTION_NOTIFICATION_CLICKED); 
filter.addCategory(Intent.CATEGORY_HOME);
registerReceiver(NotificationClickReceiver, filter);

That should ensure that you always receive the same broadcasts as the manifest registered receiver.

Solution 2:

All matching BroadcastRecievers will be notified, with their appropriate Context. Note that this can happen in two ways:

  1. If a Receiver is locally created in code and registered, inside some object, it will be called only if that object is around.

  2. If an Reciever is declared in manifest, that object will be created and onReceive() method will be called.

So, you can have Service class implement BroadCastReciever, declare it in Manifest file, and start your service form its onRecieve();

Post a Comment for "Is It Possible That Two Broadcastreceiver From Two Apps, Based On The Same Broadcast Intent Action, Somehow "collide"?"