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的更多相关文章

  1. Android英文文档翻译系列(1)——AlarmManager

      原文:个人翻译,水平有限,欢迎看官指正.                                                              public class Ala ...

  2. Android英文文档翻译系列(5)——VPNService

      API14位于android.net.VpnService 类概述|Class OverviewVpnService is a base class for applications to ext ...

  3. Android英文文档翻译系列(4)——PopupWindow

    public class PopupWindow extends Object //直接继承至Object java.lang.Object ↳ android.widget.PopupWindow  ...

  4. Android英文文档翻译系列(3)——AsyncTask

      AsyncTask——异步任务   个人认为这是翻译比较好的一次.. Class Overview//类概述 AsyncTask enables proper and easy use of th ...

  5. Android英文文档翻译系列(2)——HandlerThread

      public class   HandlerThread extends Thread   Class  Overview Handy class for starting a new threa ...

  6. Android进阶——多线程系列之Thread、Runnable、Callable、Future、FutureTask

    多线程一直是初学者最抵触的东西,如果你想进阶的话,那必须闯过这道难关,特别是多线程中Thread.Runnable.Callable.Future.FutureTask这几个类往往是初学者容易搞混的. ...

  7. Android提升篇系列:Activity recreate(Activity 重新创建/自我恢复)机制(一)

    注:本文中的recreate是指当内存不足时,Activity被回收,但再次来到此Activity时,系统重新恢复的过程.例如:当Activity A到Activity B时,如果内存不足,A被回收, ...

  8. Android控件系列之RadioButton&RadioGroup(转)

    学习目的: 1.掌握在Android中如何建立RadioGroup和RadioButton 2.掌握RadioGroup的常用属性 3.理解RadioButton和CheckBox的区别 4.掌握Ra ...

  9. Android网络编程系列 一 TCP/IP协议族

    在学习和使用Android网路编程时,我们接触的仅仅是上层协议和接口如Apache的httpclient或者Android自带的httpURlconnection等等.对于这些接口的底层实现我们也有必 ...

随机推荐

  1. Java如何在正则表达式中匹配重复单词?

    在Java编程中,如何在正则表达式中匹配重复单词? 以下示例显示了如何使用regex.Matcher类的p.matcher()方法和m.group()方法在正则表达式中搜索重复的单词. package ...

  2. JUnit教程

    测试是检查应用程序是否是工作按照要求,并确保在开发者水平,单元测试进入功能性的处理.单元测试是单一实体(类或方法)的测试. 单元测试在每一个软件公司开发高品质的产品给他们的客户是十分必要的. 单元测试 ...

  3. logbook日志系统

    python中替代logging的日志系统. 不过比之前的logging难理解. 先上打印到屏幕上的代码和存到日志文件中的代码: #!/usr/bin/env python3 # -*- coding ...

  4. unity5x --------Music Mixer参数详解

      我们一直在致力开发出业界最顶尖水准音频处理功能,而经过很长一段时间的努力,在Unity5.0中,音频处理功能将成为非常重点的一个功能. 要达成这个目标,我们首先重写了很多Unity中音频相关得处理 ...

  5. (转)Android分布式编译学习(一)distcc实现分布式编译 —— Ubuntu12.04上部署distcc分布式编译

    转自:http://blog.csdn.net/eqiang8271/article/details/17144411   版权声明:本文为博主原创文章,未经博主允许不得转载. Android代码庞大 ...

  6. php 判定pc端與移動端

    1.親測有效 2.上代買 //判斷移動端,pc端 /*移动端判断*/ public static function isMobile() { // 如果有HTTP_X_WAP_PROFILE则一定是移 ...

  7. Java对象的序列化与反序列化-Json篇

    说到Java对象的序列化与反序列化,我们首先想到的应该是Java的Serializable接口,这玩意在两个系统之间的DTO对象里面可能会用到,用于系统之间的数据传输.或者在RPC(远程方法调用)时可 ...

  8. iOS:if a ViewController is Visible

    from:stackoverflow The view's window property is non-nil if a view is currently visible, so check th ...

  9. 【伪装位置神器】神行者AnyLocation 1.3.0001可用于微信,陌陌

    <ignore_js_op> 软件名称:神行者(破解)软件版本:v1.3.0001授权类别:免费测试机型:大可乐手机 下载链接: http://pan.baidu.com/s/1qWwSM ...

  10. Node.js之exports与module.exports

    每一个node.js执行文件,都自动创建一个module对象,同时,module对象会创建一个叫exports的属性,初始化的值是 {} module.exports = {}; Node.js为了方 ...