How can I serve multiple AIDL interfaces from a single Service? The scenario is the following:
|---Client_1
|--AIDL1--| ...
| |---Client_6
MyService |
| |---Client_4
|--AIDL2--| ...
|---Client_9
My idea was to use the intent from the method public IBinder onBind(Intent intent)
to somehow find out the type of client application calling and the AIDL in which this client is interested in. Is this possible?
I also have the same question and write the prototype for testing. Actually it should works by examine the intent and return different binder according to the intent extras.
But after testing, I found the onBind only call once for the first client. After that, system will return the cached binder to later clients who want to bind the service.
Android official document describe
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.
I still try to find ways but it seems not possible to do that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With