Android bind with existing service across multiple apps -
i have service implemented in module a. apps b , c uses library bind service using bindservice(service, connection, bind_auto_create)
creates new instance of service. i'm using messenger
return binder connection objects. if use aidl, how sharing same service instance achieved? i've read , tried stackoverflow answers related question. still i'm not able achieve explained above.
manifest of service defined inside module full process name process attribute , exported,enabled set true.
<service android:name="io.packagename.locationservice" android:enabled="true" android:exported="true" android:permission="android.permission.access_fine_location" android:process="io.packagename.locationservice" />
locationservice-class:
class locationservice extends service { incominghandler handler = new incominghandler() messenger messenger = new messenger(handler) public ibinder onbind(intent intent) { log.d(tag, "onbind") return messenger.binder } }
any appreciated.
quoting docs:
as discussed in services document, can create service both started , bound. is, service can started calling startservice(), allows service run indefinitely, , allow client bind service calling bindservice().
an example:
for example, music player might find useful allow service run indefinitely , provide binding. way, activity can start service play music , music continues play if user leaves application. then, when user returns application, activity can bind service regain control of playback.
i believe applies case, can start service , bind clients needed.
Comments
Post a Comment