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 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的更多相关文章
- Android英文文档翻译系列(1)——AlarmManager
原文:个人翻译,水平有限,欢迎看官指正. public class Ala ...
- Android英文文档翻译系列(5)——VPNService
API14位于android.net.VpnService 类概述|Class OverviewVpnService is a base class for applications to ext ...
- Android英文文档翻译系列(4)——PopupWindow
public class PopupWindow extends Object //直接继承至Object java.lang.Object ↳ android.widget.PopupWindow ...
- Android英文文档翻译系列(3)——AsyncTask
AsyncTask——异步任务 个人认为这是翻译比较好的一次.. Class Overview//类概述 AsyncTask enables proper and easy use of th ...
- Android英文文档翻译系列(2)——HandlerThread
public class HandlerThread extends Thread Class Overview Handy class for starting a new threa ...
- Android进阶——多线程系列之Thread、Runnable、Callable、Future、FutureTask
多线程一直是初学者最抵触的东西,如果你想进阶的话,那必须闯过这道难关,特别是多线程中Thread.Runnable.Callable.Future.FutureTask这几个类往往是初学者容易搞混的. ...
- Android提升篇系列:Activity recreate(Activity 重新创建/自我恢复)机制(一)
注:本文中的recreate是指当内存不足时,Activity被回收,但再次来到此Activity时,系统重新恢复的过程.例如:当Activity A到Activity B时,如果内存不足,A被回收, ...
- Android控件系列之RadioButton&RadioGroup(转)
学习目的: 1.掌握在Android中如何建立RadioGroup和RadioButton 2.掌握RadioGroup的常用属性 3.理解RadioButton和CheckBox的区别 4.掌握Ra ...
- Android网络编程系列 一 TCP/IP协议族
在学习和使用Android网路编程时,我们接触的仅仅是上层协议和接口如Apache的httpclient或者Android自带的httpURlconnection等等.对于这些接口的底层实现我们也有必 ...
随机推荐
- SpringMVC系列(八)国际化
一.页面国际化 1.在pom.xml引入国际化需要的依赖 <!--国际化相关依赖 begin --> <dependency> <groupId>jstl</ ...
- 架构 : 三层架构、MVC、MVP、MVVM
1. 三层架构 将整个业务应用划分为:界面层(User Interface layer, UIL).业务逻辑层(Business Logic Layer, BLL).数据访问层(Data acce ...
- Python——eventlet.wsgi
eventlet 的 wsgi 模块提供了一种启动事件驱动的WSGI服务器的简洁手段,可以将其作为某个应用的嵌入web服务器,或作为成熟的web服务器,一个这样的web服务器的例子就是 Spawnin ...
- 精巧好用的DelayQueue
我们谈一下实际的场景吧.我们在开发中,有如下场景 a) 关闭空闲连接.服务器中,有很多客户端的连接,空闲一段时间之后需要关闭之.b) 缓存.缓存中的对象,超过了空闲时间,需要从缓存中移出.c) 任务超 ...
- Java设计模式之五大创建型模式(附实例和详解)
一.概况 总体来说设计模式分为三大类: (1)创建型模式,共五种:工厂方法模式.抽象工厂模式.单例模式.建造者模式.原型模式. (2)结构型模式,共七种:适配器模式.装饰器模式.代理模式.外观模式.桥 ...
- Linux下MySQL开放root的远程访问权限
mysql默认只能从本地连接,所以要使root可以远程访问登录,需做如下设置: 1.授权 请使用以下命令 mysql> Grant all privileges on *.* to 'root' ...
- 【Objective-C】Http常用API、同步请求与异步请求[转]
比较实用, 转载保存 开发iOS应用要调用Http接口.获取Http资源,有一套比较成熟的框架ASIHTTPRequest.而我还是比较喜欢使用原始一点的API,而它跟其他的面向对象语言有许多共通之处 ...
- js中如何以最简单的方式将数组元素添加到对象中
//如题,通常做法就是循环数组,最后在添加length属性,如: var obj = {}; var pushArr = [11,22,33,44,55,66]; for(var i=0;i<p ...
- git绑定两个远程仓库
最近在做公司项目,之前公司项目统一托管在codding 码云,最近我想把项目与自己的gitlab私人仓库再连接一下,作为自己作品收录的地方,这里总结一下用到的git命令及问题. 1.首先, 找到当前已 ...
- 解决网页响应慢,waiting(TTFB)时间过长
今天下午发现写的一个功能里,ajax等待时间过长 可以看到是waiting(TTFB)时间过长要1秒左右 用浏览器打开PHP页面测试,还是同样问题 将该接口的数据,都注释掉 发现是pdo连接数据库造成 ...