什么是Android的sendStickyBroadcast和sendBroadcast之间的区别 [英] what is the difference between sendStickyBroadcast and sendBroadcast in Android

查看:253
本文介绍了什么是Android的sendStickyBroadcast和sendBroadcast之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android的 sendStickyBroadcast sendBroadcast 之间的区别是什么?

What is the difference between sendStickyBroadcast and sendBroadcast in Android?

推荐答案

<一个href="http://developer.android.com/reference/android/content/Context.html#sendStickyBroadcast%28android.content.Intent%29">Here是Android SDK中说,有关 sendStickyBroadcast()

执行sendBroadcast(意向),其   是粘,意思是意向你   在后发周围逗留   播放完毕,让别人   可以快速通过检索数据   的返回值   registerReceiver(BroadcastReceiver的,   IntentFilter的)。在所有其他方面,这   的行为一样   sendBroadcast(意向)。

Perform a sendBroadcast(Intent) that is "sticky," meaning the Intent you are sending stays around after the broadcast is complete, so that others can quickly retrieve that data through the return value of registerReceiver(BroadcastReceiver, IntentFilter). In all other ways, this behaves the same as sendBroadcast(Intent).

通过操作系统发送持久广播的一个例子是 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之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆