Android service in library

2019-02-02 01:21发布

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);

Solution:
I created aidl for these and its working fine now.

3条回答
我想做一个坏孩纸
2楼-- · 2019-02-02 02:03

The service needs to be specified in the Manifest for your application, not the library.

查看更多
ら.Afraid
3楼-- · 2019-02-02 02:06

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)

查看更多
The star\"
4楼-- · 2019-02-02 02:18

I created aidl for these and its working fine now.

查看更多
登录 后发表回答