开发者

Redirect BroadcastReceiver onReceive()

开发者 https://www.devze.com 2023-01-20 02:00 出处:网络
What\'s the correct way (if any) to redirect a received Intent to another BroadcastReceiver? 开发者_Go百科I have two BroadcastReceivers set to listen to the same intent.It works in development, but i

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

开发者_Go百科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?

EDIT - I never figured out how to do this generically, but I came up with a solution. I wrote it up on my blog and it's pretty long so, insert shameless plug to my answer here.


Use an ordered broadcast

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

0

精彩评论

暂无评论...
验证码 换一张
取 消