Android的服务库 [英] Android service in library

查看:472
本文介绍了Android的服务库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

这是我在图书馆清单

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

这是我的apk清单

 <使用-权限的Andr​​oid:名称=com.wissen.permission.MY_SERVICE_PERMISSION>< /使用-许可>
 

当然,我并添加的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)

这篇关于Android的服务库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆