[英]How can I send property from BroadcastReceiver1 to BroadcastReceiver2?
I have one service and two BroadcastReceiver
. 我有一项服务和两个
BroadcastReceiver
。 I am calling first receiver like: 我正在给第一个接收方打电话:
private static final String CALLACTION = "android.intent.action.PHONE_STATE";
final IntentFilter theCallFilter = new IntentFilter();
theCallFilter.addAction(CALLACTION);
yourCallReceiver = new CallReceiver();
registerReceiver(yourCallReceiver, theCallFilter);
and the second one similar like first one. 第二个类似第一个。
Now I need to set data from one receiver to another. 现在,我需要将数据从一个接收器设置到另一个接收器。 I want to set
Boolean
property which will check if the code in first BroadcastReceiver
is done something and if is it then code in second can be executed. 我想设置
Boolean
属性,该属性将检查第一个BroadcastReceiver
的代码是否已完成某些操作,如果已完成,则可以执行第二个代码。 How can i send this property from "BroadcastReceiver1" to "BroadcastReceiver2" ? 如何将该属性从“ BroadcastReceiver1”发送到“ BroadcastReceiver2”?
If you simply using a BroadcastRecevier, you can't be sure the order the system will resolve them in. The answer here is to use ordered Broadcast instead. 如果仅使用BroadcastRecevier,则不能确定系统将解决这些问题的顺序。此处的答案是改为使用有序的Broadcast。 You can then set the result and check that result in your next receiver.
然后,您可以设置结果并在下一个接收器中检查该结果。 Here is a great post from the Google Blog http://android-developers.blogspot.com/2011/01/processing-ordered-broadcasts.html
这是Google Blog http://android-developers.blogspot.com/2011/01/processing-ordered-broadcasts.html上的一篇精彩文章
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.