广播接收器不按顺序运行

时间:2016-08-05 23:24:41

标签: android broadcastreceiver android-broadcast

我的应用程序中有两个函数a和b。两个功能都发送广播。就像这样:

a()  // Method a executed and sends broadcast broadcast_a
b()  // Method b executed and sends broadcast broadcast_b

我在两个广播接收器的onReceive()中都有函数a和b。 Toasts按以下顺序显示:

1. Toast from a()
2. Toast from b()
3. Toast from receiver of broadcast receiver a
4. Toast from receiver of broadcast receiver b

我无法理解为什么会这样。据我所知广播接收器在UI线程上运行,为什么会发生这种情况呢?不应该首先从广播接收器的接收器播放,然后从方法b显示吗?为什么会发生相反的情况?有人可以解释一下吗?在此先感谢!!

0 个答案:

没有答案