I have a background service running and a client which interacts with the service.
When the client requests for some operation, the service performs it and it should send the result back to the activity (client).
I know how to invoke the service methods in activity and using call backs we can achieve what I want to do. But I am not able to understand the call back mechanism and code example provided in Api demos (remoteservice).
Could someone explain how this service callback works; or anything which is achievable using simpler mechanism.
Here is the flow
Create your intent to call a service. You can either
startService()
orBindService()
withBIND_AUTO_CREATE
Once the service is bond, it will create a tunnel to talk with it clients which is the
IBinder
Interface. This is used by your AIDL Interface implementation and return theIBinder
inOnce it returns the
mBinder
,ServiceConnection
that you created in the client will be called back and you will get the service interface by using thisNow you got the
mService
interface to call and retreive any service from that