Well, I've done some considerable debugging and testing on this. My
code is based on the examples given with the SDK docs, so it's nothing
different or profound.
http://developer.android.com/intl/fr/guide/developing/tools/aidl.html
I can confirm that if you pause the activity that called the service,
when the activity is resumed it does not pick up the same connection
object. This means that when you subsequently stop the service, the
old connection is still hanging around (although you can't access it)
meaning the service's onDestroy() doesn't get called. The only way to
make sure the service is destroyed is to destroy the activity too -
which really isn't what I want to do in this case.
Mark, or anyone else, if you have any suggestions I would appreciate
it. Here's the code where the connection is created:
private ServiceConnection m_connection = new ServiceConnection(){
@Override
public void onServiceConnected(ComponentName name, IBinder
service)
{
m_service = ILocationService.Stub.asInterface(service);
}
@Override
public void onServiceDisconnected(ComponentName name) {
m_service = null;
}
};
> So it seems like the onDestroy() method should be called, unless there
> is more than one connections existing. Is it possible that when my
> activity is resumed, a new connection object is created, making a
> second one hanging onto the service?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en