5.0绑定远程服务的两种方式
来源:互联网 发布:金汇宝炒股软件 编辑:程序博客网 时间:2024/06/05 18:36
前言:
今天闲下来翻了下以前的笔记,然后就做了个Demo,简单的使用两个apk来模拟服务端和客户端,用两种方式来绑定远程服务,实现IPC通讯。
实现要点:
1,先看客户端效果:
2,看两个项目的工程结构:
3,看客户端绑定远程服务的关键代码:
//第一种绑定方式final Intent intentPay = new Intent();intentPay.setAction("com.xhunmon.remote.PayService");final Intent eintent = new Intent(createExplicitFromImplicitIntent(this,intentPay));bindService(eintent,new Conn(), Service.BIND_AUTO_CREATE);//第二种绑定方式Intent intentPlayer = new Intent();intentPlayer.setClassName("com.xhunmon.aidlserver","com.xhunmon.aidlserver.PlayerService");bindService(intentPlayer,mServiceConnection,Service.BIND_AUTO_CREATE);
第一种绑定的方式action要与服务端的一样,而第二种则设置setClassName(服务端包名,服务端服务的全路径),清单文件中代码如下:
<service android:name=".PayService"> <intent-filter> <action android:name="com.xhunmon.remote.PayService"/> </intent-filter></service><service android:name=".PlayerService" android:process=":PlayerService" android:enabled="true" android:exported="true"></service>
[1] GitHub项目地址:https://github.com/xhunmon/AidlPay.git
阅读全文
0 0
- 5.0绑定远程服务的两种方式
- 远程服务的绑定
- 两种绑定DropDownList数据源的方式
- WPF combobox 的两种绑定方式
- 绑定服务&绑定远程服务
- 引用WCF服务的两种方式.
- servlet启动服务的两种方式
- Dubbo服务配置的两种方式
- Android -- service的开启方式, start开启和绑定开启服务,调用服务的的方法, aidl调用远程服务
- android,aidl,绑定远程服务,调用远程服务的方法
- GridView绑定两个表的内容的两种方式:SQL查询,绑定再绑定
- D 04_JS事件的两种绑定方式,元素绑定和DOM绑定
- javascript的事件绑定的两种方式详解
- 绑定远程服务时的上下文问题
- 绑定远程服务的流程aidl
- android 的aidl绑定远程服务
- extjs使用回车绑定查询按钮的两种方式
- MultiActionController绑定表单数据的两种实现方式
- Python基础-多线程
- HTML—js:利用History对象实现页面跳转
- 面试礼仪为你加分
- c++的unique函数
- Unity Learning for Day 26
- 5.0绑定远程服务的两种方式
- 51nod 1102
- JDBC批处理sql
- react-native Alert组件
- 整数转换成罗马数字 python
- bzoj 1045: [HAOI2008]糖果传递
- zookeeper的简单使用
- 剑指offer——平衡二叉树
- 剑指Offer----替换空格