views:

28

answers:

1

What's the correct way (if any) to redirect a received Intent to another BroadcastReceiver?

I have two BroadcastReceivers set to listen to the same intent. It works in development, but in production, only the first one registered in the manifest gets the intent.

Can I call the other one's onReceive() method directly, passing the same context and intent? Is there a better way to pass the intent along once the first receiver is done with it?

A: 

Use an ordered broadcast

http://developer.android.com/reference/android/content/Context.html#sendOrderedBroadcast%28android.content.Intent,%20java.lang.String%29

Falmarri
@Falmarri - Unfortunately I'm not sending the original broadcast. If I were to do that from my registered receiver, I think it might cause an infinite loop, no?
DougW
Oh, I my mistake, I thought you were sending it. Well there's 2 issues I see. 1.) Why do you have 2 receivers listening to the same intent? 2.) Are you sure it's not a bug in your code such that your second receiver isn't getting the intent?
Falmarri
@Falmarri - Yes, I'm intercepting Google Analytics' installation intent broadcast. When I test it by broadcasting my own intent, both receivers get it. When the app goes live, however, only Google's receiver gets it. I've fixed this by only registering my own, and calling Google's onReceive() method manually.
DougW