tags:

views:

56

answers:

1

Is there a way to find out if an activity is bound to a service? Something like boolean isBoundToService(ServiceConnection sc)?

Sometimes when I play around with my app I get an exception when it tries to unbind a service which is not bound.

+6  A: 

I don't believe there's a method you can call to find this out. However, what I've commonly seen done is to keep a boolean in the activity that tracks whether or not the service is bound. You'd set it to true in your ServiceConnection.onServiceConnected() callback and set it to false in ServiceConnection.onServiceDisconnected().

Erich Douglass