自定义广播(Broadcast)
来源:互联网 发布:java三大框架教程区别 编辑:程序博客网 时间:2024/05/22 17:19
转自:http://blog.sina.com.cn/s/blog_7dbac125010191sf.html
BroadcastReceiver
简单的实现自定义广播(Broadcast)机制
首先在ManiFset文件当中定义一个Receiver,并设置intent-filter
例如:
<receiver android:name=".SendDownXMLBroadCast"><span style="white-space:pre"></span><intent-filter ><span style="white-space:pre"></span><!--自定义广播--><span style="white-space:pre"></span><action android:name="com.neter.broadcast.receiver.SendDownXMLBroadCast"/><span style="white-space:pre"></span></intent-filter></receiver>
接下来就是在activity当中设置自定义的广播,如下:
Intent intent = new Intent();intent.setAction("com.neter.broadcast.receiver.SendDownXMLBroadCast");//发出自定义广播context.sendBroadcast(intent);最后就是广播接收器的实现:
public class SendDownXMLBroadCast extends BroadcastReceiver {<span style="white-space:pre"></span>public void onReceive(Context context, Intent intent) {<span style="white-space:pre"></span>System.out.println("send BroadCast seccess!");<span style="white-space:pre"></span>Intent intent2=new Intent(context, DownFriendXML.class);<span style="white-space:pre"></span>context.startService(intent2);}
0 0
- Broadcast--自定义广播
- 自定义广播(Broadcast)
- Broadcast学习之发送自定义广播
- 简单的实现自定义广播(Broadcast)机制
- protected-broadcast 系统应用自定义广播规范
- Broadcast-----------自定义Action , 两种方式 实现广播Broadcast
- Broadcast-----------自定义Action , 两种方式 实现广播Broadcast
- Android开发:广播机制:Broadcast——自定义广播方法
- Android自定义广播(Broadcast)与系统广播
- broadcast广播
- Broadcast广播
- broadcast 广播
- Broadcast广播
- broadcast广播
- Broadcast广播
- 广播 (Broadcast)
- 广播Broadcast
- Broadcast广播
- inparanoid
- POJ 2524Ubiquitous Religions
- 车辆保养记录查询
- css 实现文本省略号:单行多行
- Linux 常用命令
- 自定义广播(Broadcast)
- 第四周《C语言及程序设计》实践项目32 二维数组及其定义
- 银行发现区块链技术很难落实
- numpy基础——ndarray对象属性
- 站点搭建笔记(WordPress+zencart+discuz+UCenter)
- 单片机数码管显示
- 手机右键按两下就退出程序
- Caffe中的特殊layer解释
- WinCE的开发流程