问题描述
在Android的 sendStickyBroadcast
和 sendBroadcast
之间的区别是什么?
What is the difference between sendStickyBroadcast
and sendBroadcast
in Android?
推荐答案
Here是Android SDK中说,有关 sendStickyBroadcast()
:
执行sendBroadcast(意向),其 是粘,意思是意向你 在后发周围逗留 播放完毕,让别人 可以快速通过检索数据 的返回值 registerReceiver(BroadcastReceiver的, IntentFilter的)。在所有其他方面,这 的行为一样 sendBroadcast(意向)。
通过操作系统发送持久广播的一个例子是 ACTION_BATTERY_CHANGED
。当你调用 registerReceiver()
的行动 - 即使有空
的BroadcastReceiver
- 你得到的意图
这是最后一次播出的行动。因此,你可以用它来发现电池的状态,而不必登记在电池的所有未来状态的变化。
One example of a sticky broadcast sent via the operating system is ACTION_BATTERY_CHANGED
. When you call registerReceiver()
for that action -- even with a null
BroadcastReceiver
-- you get the Intent
that was last broadcast for that action. Hence, you can use this to find the state of the battery without necessarily registering for all future state changes in the battery.
这篇关于什么是Android的sendStickyBroadcast和sendBroadcast之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!