android - 广播接收器优先级和中止广播

标签 android android-broadcast

我是 android 的初学者。我搜索了很多网站。但我无法理解这个主题。请告诉我为什么以及如何以及何时在 BroadcastReceiver 中使用 priority & aborting。谢谢!!

最佳答案

来自 docs :

There are two major classes of broadcasts that can be received:

  • Normal broadcasts (sent with Context.sendBroadcast) are completely asynchronous. All receivers of the broadcast are run in an undefined order, often at the same time. This is more efficient, but means that receivers cannot use the result or abort APIs included here.

  • Ordered broadcasts (sent with Context.sendOrderedBroadcast) are delivered to one receiver at a time. As each receiver executes in turn, it can propagate a result to the next receiver, or it can completely abort the broadcast so that it won't be passed to other receivers. The order receivers run in can be controlled with the android:priority attribute of the matching intent-filter; receivers with the same priority will be run in an arbitrary order.

关于android - 广播接收器优先级和中止广播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23425229/

相关文章:

android - Wifi 扫描结果未广播

android - 在android中注册广播接收器

android - BOOT_COMPLETED 未在设备中调用

java - 长按在 ListView 行上不起作用

c# - Unity3D 使用 OnTriggerStay

android - 如何在布局中制作从右到左的动画

android - 星巴克在商店附近时如何在 Android 设备上显示 UI?

android - 奥利奥 : Broadcast receiver Not working

android - 如何在 fragment 中实现按钮 SetOnClickListener?

android - 在 Android 中启用禁用蓝牙