AIDL ServiceConnection.OnServiceDisconnected() not called
<p>I'm doing an IPC between a client Activity and a Service using AIDL. ServiceConnection.onServiceConnected() seems to run when binding the Service with bindService(). However after unbindService() is called when releasing the Service, there's no indication ServiceConnection.onServiceDisconnected() is ever run. Can anybody provide any insight as to why this happens? </p>

<p>Found another thread on this issue here:
<a href="http://stackoverflow.com/questions/971824/when-does-serviceconnection-onservicedisconnected-get-called">http://stackoverflow.com/questions/971824/when-does-serviceconnection-onservicedisconnected-get-called</a></p>

<p>Which doesn't quite answer my question. My Service didn't fail on any exception.</p>

<p>Here's my service binding and releasing code:</p>

<pre><code>//bind service
private void initService()
{
    conn = new NetServiceConnection();
    Intent i = new Intent();
    i.setClassName( "framework.network", "framework.network.NetService" );
    bindService( i, conn, Context.BIND_AUTO_CREATE);//This returns TRUE
}

//unbind service
private void releaseService()
{
    unbindService(conn);
    conn = null;
}

class NetServiceConnection implements ServiceConnection
{

    //THIS RUNS FINE
    public void onServiceConnected(ComponentName name, IBinder service) {
         mService = INetService.Stub.asInterface(service);
          Log.d( "ADDERSERVICECLIENT","onServiceConnected" );
    }

    //THIS DOESN'T RUN
    public void onServiceDisconnected(ComponentName name) {
        mService = null;
        Log.d( "ADDERSERVICECLIENT","onServiceDisconnected" );
    }
};
</code></pre>

<p>Any help is very much appreciated. Thanks in advance.</p>
