Android Service: onBind(Intent) and onUnbind(Intent) is called just once Android Service: onBind(Intent) and onUnbind(Intent) is called just once android android

Android Service: onBind(Intent) and onUnbind(Intent) is called just once


I think this (referenced from official dev guide) can explain all your queries:

Multiple clients can connect to the service at once. However, the system calls your service's onBind() method to retrieve the IBinder only when the first client binds. The system then delivers the same IBinder to any additional clients that bind, without calling onBind() again.


You can find it here:https://developer.android.com/guide/components/bound-services.html

You can connect multiple clients to a service simultaneously. However, the system caches the IBinder service communication channel. In other words, the system calls the service's onBind() method to generate the IBinder only when the first client binds. The system then delivers that same IBinder to all additional clients that bind to that same service, without calling onBind() again.


You can unbind all the clients, then the service will be destroyed, and then the onBind will be called, if this is what you want.