gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 02:55:01 26 4
gpt4 key购买 nike

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

最佳答案

来自 docs :

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

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

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

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com