I am writing a service for my Android app and I am trying to understand how the binding mechanism works.
If I bind my service in the onCreate of an activity but I don’t unbind it in onStop or onDestroy, I get the error :
android.app.ServiceConnectionLeaked: Service com.google.ipc.invalidation.ticl.android.AndroidInvalidationService has leaked ServiceConnection com.googl
e.ipc.invalidation.external.client.android.service.ServiceBinder$1@4177f8f8 that was originally bound here
So my question is : what is the problem exactly with leaking a connection, what am I preventing by unbinding my service ?
That happens when Android OS destroys
Activityand finds that aServiceConnectionstill bound to a runningService, so you need to unbind the service before destroying yourActivity