AIDL service纪事 注意事项
2016-02-23 01:01
302 查看
本人学习AIDL实现过程遇到的几个问题记录:
1.
aidl文件的描述中的package ,服务端代码的路径(如 package com.allan.hs.services;)是包名;而本地(服务端代码)实现它的service中, <service
android:name="com.allan.hs.services.AHWKeysService"
android:exported="true"
android:process=":remote" >
<intent-filter>
<action android:name="com.allan.hs.services.IAIDLService" />
</intent-filter>
</service>
注意两点,<action android:name="XXXX" /> 请从gen目录确认名字。
2.
Service Intent must be explitict.
5.0 api 在客户端代码调用intent有差异。注意第一个包名是路径,第二是app包名。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.allan.hearthstoneanalysis"
android:versionCode="1"
android:versionName="1.0" ><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.allan.hsa"
android:versionCode="1"
android:versionName="1.0" >
Intent it = new Intent("com.allan.hs.services.IAIDLService").setPackage("com.allan.hsa");
bindService(it, mRemoteConnection,
Context.BIND_AUTO_CREATE);
3. SecurityException: Binder invocation to an incorrect interface
需要确保客户端中,aidl 也放在com.allan.hs.services这个路径下。
4. 服务对象NULLpointerException,或者onServiceConnected()没有被调用
请确认服务端是否onBind()中return了。
不自己写永远不知道有这么多问题。mark一下。
1.
aidl文件的描述中的package ,服务端代码的路径(如 package com.allan.hs.services;)是包名;而本地(服务端代码)实现它的service中, <service
android:name="com.allan.hs.services.AHWKeysService"
android:exported="true"
android:process=":remote" >
<intent-filter>
<action android:name="com.allan.hs.services.IAIDLService" />
</intent-filter>
</service>
注意两点,<action android:name="XXXX" /> 请从gen目录确认名字。
2.
Service Intent must be explitict.
5.0 api 在客户端代码调用intent有差异。注意第一个包名是路径,第二是app包名。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.allan.hearthstoneanalysis"
android:versionCode="1"
android:versionName="1.0" ><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.allan.hsa"
android:versionCode="1"
android:versionName="1.0" >
Intent it = new Intent("com.allan.hs.services.IAIDLService").setPackage("com.allan.hsa");
bindService(it, mRemoteConnection,
Context.BIND_AUTO_CREATE);
3. SecurityException: Binder invocation to an incorrect interface
需要确保客户端中,aidl 也放在com.allan.hs.services这个路径下。
4. 服务对象NULLpointerException,或者onServiceConnected()没有被调用
请确认服务端是否onBind()中return了。
不自己写永远不知道有这么多问题。mark一下。
相关文章推荐
- 人工智能 有限状态机 的时代过去了
- could not obtain the localhost address
- Rails 中的事物处理
- Maven-010-maven 编译报错:Failure to ... in ... was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced.
- 可执行程序的入口点在那里?(强化概念:程序真正的入口是mainCRTstartup)
- Educational Codeforces Round 8 F. Bear and Fair Set(最大流 | Hall定理)
- POJ1704--Georgia and Bob--staircase nim
- CodeForces 50B Choosing Symbol Pairs
- Event Pairs
- RAID在企业服务器中的应用(RAID几种级别)
- Class类文件结构浅析 http://blog.csdn.net/kobejayandy/article/details/39620833
- Aizu 2305
- A. Again Twenty Five!
- MTK MAINAF-->2-000c
- 贪吃蛇的实现及其简单AI设计
- Jenkins进阶系列之——03parameterized-trigger插件
- Jenkins进阶系列之——01使用email-ext替换Jenkins的默认邮件通知
- The RAII Programming Idiom
- grails中的相关约定
- .container类的说明