跨应用发送和接受广播
来源:互联网 发布:亨德尔 水上音乐 知乎 编辑:程序博客网 时间:2024/05/19 02:41
跨应用发送和接收广播,与同应用下的情况差不多,只需要添加一个权限,以及配置一下receiver的android:process属性即可
发送广播的应用中:
- Intent intent = new Intent("info.zhegui.receiver.interprocess");
- sendBroadcast(intent);
注意要在manifest.xml添加接收广播的权限,这个权限是receiver自定义的
- <uses-permission android:name="info.zhegui.receiver.RECEIVE"/>
接收广播的应用中:
- public class MyReceiver extends BroadcastReceiver {
- private final String TAG = this.getClass().getName();
- @Override
- public void onReceive(Context content, Intent intent) {
- Log.i(TAG, "intent:" + intent);
- }
- }
在manifest.xml中添加自定义权限,以及配置receiver的几个属性
- <permission android:name="info.zhegui.receiver.RECEIVE" />
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/AppTheme" >
- <receiver
- android:name="info.zhegui.receiver.MyReceiver"
- android:exported="true"
- android:permission="info.zhegui.receiver.RECEIVE"
- android:process=":remote" >
- <intent-filter>
- <action android:name="info.zhegui.receiver.interprocess" />
- </intent-filter>
- </receiver>
- </application>
需要注意的三个地方:
1,自定义权限
2,android:exported="true"
3,android:process=":remote" (有时候可以不要该属性)
0 0
- 跨应用发送和接受广播
- 接受和发送广播
- 接受和发送广播
- Android广播的发送和接受
- android 跨应用程序广播发送接受
- 跨应用(跨进程)发送广播和接收广播
- 跨应用(跨进程)发送广播和接收广播
- Android应用开发-----------------接受照相机拍照广播和录像广播
- 接受和发送广播------开机启动和接收短信
- android中BroadCastReceiver使用(广播的接受和发送)
- android 随手记 广播的发送和接受
- android 随手记 广播的发送和接受
- Android中 广播发送 和 接受 的简单示例
- 广播的发送和接受过程是怎样的
- 自定义 发送广播,并接受广播
- UDP广播和接受
- JMS发送和接受
- Socket发送和接受
- C++开发者都应该使用的10个C++11特性
- 第9题
- 欢迎使用CSDN-markdown编辑器
- 移动端前端笔记大全
- Leetcode Merge Sorted Array 关于算法效率的思考
- 跨应用发送和接受广播
- group by 的使用
- 重要的开源资源及50个c/c++源代码网站
- 前端面试 - Http Session问题,记录我愚蠢的回答=。=
- C++第五章作业
- 正则表达式
- Android 实现监听开机启动开启后台服务,并实现自动重启。
- POJ 2367 拓扑排序
- 第十四周项目1-3:统计字符个数