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

前端 未结 2 1138
慢半拍i
慢半拍i 2020-12-24 05:38

I have the Activity and the Service. When Activity is started, it calls startService() to make this Service be alive even when Activity is destroyed, and

相关标签:
2条回答
  • 2020-12-24 06:07

    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.

    0 讨论(0)
  • 2020-12-24 06:12

    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.

    0 讨论(0)
提交回复
热议问题