Android的服务库Android

2023-09-04 05:51:18 作者:帅死鬼i

我创建的库与该服务我想成为能够结合在一个以上的apk

这是我在图书馆清单

 <服务类=机器人service.MyService。:权限=com.wissen.permission.MY_SERVICE_PERMISSION>
<意向滤光器>
<作用安卓值=com.wissen.testApp.service.MY_SERVICE/>
&所述; /意图滤光器>
< /服务>
 

这是我的apk清单

 <使用-权限的Andr​​oid:名称=com.wissen.permission.MY_SERVICE_PERMISSION>< /使用-许可>
 
Android移动开发技术文章 手机开发

当然,我并添加的lib到APK。我不断获取未找到(警告)服务。我究竟做错了。

我这样绑定

  bindService(新的意向书(com.wissen.testApp.service.MY_SERVICE),康涅狄格州,Context.BIND_AUTO_CREATE);
 

解决方案

您服务必须是远程服务。您应该创建一个* .aidl(接口为您服务),并在它自己的程序启动。 你可以在这里阅读有关:的Andr​​oid接口定义语言(AIDL)

i created a library with a service in that i want to be able to bind to in more than one apk.

This is in my libraries manifest

<service class=".service.MyService" android:permission="com.wissen.permission.MY_SERVICE_PERMISSION">
<intent-filter>
<action android:value="com.wissen.testApp.service.MY_SERVICE" />
</intent-filter>
</service>

and this is in my apk manifest

<uses-permission android:name="com.wissen.permission.MY_SERVICE_PERMISSION"></uses-permission>

and i of course added the lib to the apk. i keep on getting service not found (warning). What am i doing wrong.

i bind it this way

bindService(new Intent("com.wissen.testApp.service.MY_SERVICE"), conn, Context.BIND_AUTO_CREATE);

解决方案

Your service must be a remote service. You should create an *.aidl (interface to your service) and start it in it's own process. You can read about it here: Android Interface Definition Language (AIDL)