Does LocalBroadcastManager deliver events in the order in which the events wer sent?

左心房为你撑大大i 提交于 2019-12-24 01:56:16

问题


I have an activity A and a service S. They commute via LocalBroadcastManager.

If S calls sendBroadcast twice with two messages M1 and M2 in order, will A get M1 before M2?

Thanks,


回答1:


LocalBroadcastManager has two ways for you to broadcast; sendBroadcast() and sendBroadcastSync(). One is synchronous, and the other is asynchronous. sendBroadcastSync() blocks until the receiver for the first message is done running.




回答2:


Not necessarily. This call deliver method is asynchronous, there is another way of sending ordered broadcasts (based on permissions, basically the one's that have more permissions get the broadcast earlier than the rest), sendOrderedBroadcast(...). You may find more info here.



来源:https://stackoverflow.com/questions/21354766/does-localbroadcastmanager-deliver-events-in-the-order-in-which-the-events-wer-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!