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

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.
See Also

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.
See Also

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.
See Also
时间: 2024-10-11 02:40:10

Android英文文档翻译系列(6)——LocalBroadcastManager的相关文章

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

原文:个人翻译,水平有限,欢迎看官指正. public class AlarmManager extends Object java.lang.Object    ? android.app.AlarmManager Class Overview This class provides access to the system alarm services. 这个类可以提供访问系统闹钟服务, These allow you to schedule your application to be r

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

API14位于android.net.VpnService 类概述|Class OverviewVpnService is a base class for applications to extend and build their own VPN solutions//VpnService一个为应用程序扩展和建立自己的VPN解决方案的基类.In general, it creates a virtual network interface, configures addresses and

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

public class PopupWindow extends Object //直接继承至Object java.lang.Object ? android.widget.PopupWindow //widget Class Overview//概述 A popup window that can be used to display an arbitrary view. The popup windows is a floating container that appears on to

Android英文文档翻译系列(5)——Creating Lists and Cards[创建List和卡片,CardView和RecyclerView]

Creating Lists and Cards To create complex lists and cards with material design styles in your apps, you can use the RecyclerView and CardView widgets. Create Lists The RecyclerView widget is a more advanced and flexible version of ListView. This wid

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

AsyncTask——异步任务 个人认为这是翻译比较好的一次.. Class Overview//类概述 AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.

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

public class HandlerThread extends Thread Class  Overview Handy class for starting a new thread that has a looper.The looper can than be used to create handler classes.Note that start() mast still not called. Handy class for starting a new thread tha

Android 源码系列之<十三>从源码的角度深入理解LeakCanary的内存泄露检测机制(中)

转载请注明出处:http://blog.csdn.net/llew2011/article/details/52958563 在上篇文章Android 源码系列之<十二>从源码的角度深入理解LeakCanary的内存泄露检测机制(上)中主要介绍了Java内存分配相关的知识以及在Android开发中可能遇见的各种内存泄露情况并给出了相对应的解决方案,如果你还没有看过上篇文章,建议点击这里阅读一下,这篇文章我将要向大家介绍如何在我们的应用中使用square开源的LeakCanary库来检测应用中出

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

在学习和使用Android网路编程时,我们接触的仅仅是上层协议和接口如Apache的httpclient或者Android自带的httpURlconnection等等.对于这些接口的底层实现我们也有必要进一步的了解,这就要我们了解网络通信层了,提到网络通信层不得不说起ISO-OSI的七层协议经典架构,如图所示: 上图的左边部分就是osi架构模型了, ISO/OSI模型,即开放式通信系统互联参考模型(Open System Interconnection Reference Model),是国际标

Android 快速开发系列 打造万能的ListView GridView 适配器

转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/38902805 ,本文出自[张鸿洋的博客] 1.概述 相信做Android开发的写得最多的就是ListView,GridView的适配器吧,记得以前开发一同事开发项目,一个项目下来基本就一直在写ListView的Adapter都快吐了~~~对于Adapter一般都继承BaseAdapter复写几个方法,getView里面使用ViewHolder模式,其实大部分的代码基本都是类似的