现在的位置: 首页 > 综合 > 正文

sendBroadcast和sendStickyBroadcast的区别

2014年03月23日 ⁄ 综合 ⁄ 共 775字 ⁄ 字号 评论关闭

我们平时最经常使用的是sendBroadcast,就是把一个Intent广播出去。今天我在看wifi的时候,还发现了sendStickyBroadcast。官方文档是这样写的: 

public abstract void sendStickyBroadcast (Intent intent) 

Since: API Level 1 
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). 
You must hold the BROADCAST_STICKY permission in order to use this API. If you do not hold that permission, SecurityException will be thrown. 
Parameters
 

intent The Intent to broadcast; all receivers matching this Intent will receive the broadcast, and the Intent will be held to be re-broadcast to future receivers. 

光从字面的意思是很难理解的。只有你写例子才会明白的。


详情:http://407827531.iteye.com/blog/1178014

抱歉!评论已关闭.