问题
I am implementing an app, in that I have two Services. One does some task and pass some value to another service and that service does some task using this value. When the first Service generate first value it should start 2nd service. Here after the values generated by the first service will be added in a queue in 2nd service. First time when the 2nd service starts I can set the value in queue using intent, but I don't know how to communicate after starting the 2nd service. How to communicate between these to services.
Anybody have some idea on this please do help me.
回答1:
As of my understanding, you may communicate in two ways:
- Bind your service(s)
- make use of BroadcastReceiver within your service(s) to exchange data/commands
However, I would suggest you not to complicate your design by involving multiple services. In fact, you should decide either you really need an ordinary service or can it be done via IntentService.
来源:https://stackoverflow.com/questions/16278468/how-to-communicate-between-background-services