I'm writting a plug-in which defines a remote Service and provides a AIDL interface for 3rd party developers.
How can I use this remote service to deal with defferent clients' concurrent requests?
It is that service apk's activitys can keep status for each client, when they switched between each other, how to do it?
This can be achieved using HandlerThread with Looper which maintains and service all the request no matter received from 100 applications.
For this AIDL callback interface is also needs to be added as request will be furnished through these callbacks.
SERVER APP
IAidlService.aidl
IAidlCallback.aidl
Stock.aidl
Stock.java
AidlService.java
This is main Service class which overrides the AIDL Service methods and implements them. It also handled the return of request with output to specific application requesting for it.
CLIENT APP
In any client app create a
ServiceConnection
and once binded to service you simply need to make Stub class for 'IAidlCallback` and send object along with getStockInfo call. Like:Hope it helps :)
Not much different than writing a multi-threaded server. You keep thread local state for each client, and maybe give them some sort of session ID so you know who you are talking to.