Android bind with existing service across multiple apps
<p>I have a Service implemented in a Module A. Now Apps B and C uses this library to bind with service using <code>bindService(service, connection, BIND_AUTO_CREATE)</code> but it always creates a new instance of Service. I'm using <code>Messenger</code> 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.</p>

<p>Manifest of this Service is defined inside Module A with full process name for process attribute and exported,enabled are set to true.</p>

<pre><code> &lt;service
        android:name="io.packagename.LocationService"
        android:enabled="true"
        android:exported="true"
        android:permission="android.permission.ACCESS_FINE_LOCATION"
        android:process="io.packagename.locationService" /&gt;
</code></pre>

<p>LocationService-Class:</p>

<pre><code>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
        }
      }
</code></pre>

<p>Any help is much appreciated.</p>