How to communicate between background services

Deadly 提交于 2019-12-19 11:36:05

问题


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:

  1. Bind your service(s)
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!