码迷,mamicode.com
首页 > 移动开发 > 详细

Android英文文档翻译系列(6)——LocalBroadcastManager

时间:2015-02-28 15:56:05      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:

public class

LocalBroadcastManager

extends Object

java.lang.Object
   ? android.support.v4.content.LocalBroadcastManager

Class Overview


Helper to register for and send broadcasts of Intents to local objects within your process. This is has a number of advantages over sending global broadcasts withsendBroadcast(Intent):

  • You know that the data you are broadcasting won‘t leave your app, so don‘t need to worry about leaking private data.
  • It is not possible for other applications to send these broadcasts to your app, so you don‘t need to worry about having security holes they can exploit.
  • It is more efficient than sending a global broadcast through the system.

 

Summary


Public Methods
static LocalBroadcastManager getInstance(Context context)
void registerReceiver(BroadcastReceiver receiver, IntentFilter filter)
Register a receive for any local broadcasts that match the given IntentFilter.
boolean sendBroadcast(Intent intent)
Broadcast the given intent to all interested BroadcastReceivers.
void sendBroadcastSync(Intent intent)
Like sendBroadcast(Intent), but if there are any receivers for the Intent this function will block and immediately dispatch them before returning.
void unregisterReceiver(BroadcastReceiver receiver)
Unregister a previously registered BroadcastReceiver.
[Expand]
Inherited Methods
技术分享 From class java.lang.Object
 

Public Methods


public static LocalBroadcastManager getInstance (Context context)

 
 

public void registerReceiver (BroadcastReceiver receiver, IntentFilter filter)

 

Register a receive for any local broadcasts that match the given IntentFilter.

Parameters
receiver The BroadcastReceiver to handle the broadcast.
filter Selects the Intent broadcasts to be received.

public boolean sendBroadcast (Intent intent)

 

Broadcast the given intent to all interested BroadcastReceivers. This call is asynchronous; it returns immediately, and you will continue executing while the receivers are run.

Parameters
intent The Intent to broadcast; all receivers matching this Intent will receive the broadcast.

public void sendBroadcastSync (Intent intent)

 

Like sendBroadcast(Intent), but if there are any receivers for the Intent this function will block and immediately dispatch them before returning.

public void unregisterReceiver (BroadcastReceiver receiver)

 

Unregister a previously registered BroadcastReceiver. All filters that have been registered for this BroadcastReceiver will be removed.

Parameters
receiver The BroadcastReceiver to unregister.

Android英文文档翻译系列(6)——LocalBroadcastManager

标签:

原文地址:http://www.cnblogs.com/bvin/p/4305497.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!