I have a Service implemented in a Module A. Now Apps B and C uses this library to bind with service using bindService(service, connection, BIND_AUTO_CREATE)
but it always creates a new instance of Service. I'm using Messenger
to return binder to the connection objects. If I use AIDL, how sharing the same service instance is achieved? I've read and tried almost all stackoverflow answers related to this question. But still I'm not able to achieve what I explained above.
Manifest of this Service is defined inside Module A with full process name for process attribute and exported,enabled are set to 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 help is much appreciated.