本文介绍了两个服务之间的通信的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,一个活动可以使用的IBinder接口的本地服务进行通信;我试图找到两个服务之间的通信方式。

I know that an activity can communicate with a local service using the IBinder interface; I am trying to find a way for communication between two services.

具体来说,我有我的主要服务启动一个IntentService来处理文件上传。我想一旦完成上传这个IntentService通知返回到主服务,它死了。

Specifically, I have my main service starting an IntentService to handle file uploads. I want this IntentService to inform back to the main service once it is done uploading, and before it dies.

有关如何这会发生任何想法?

Any ideas about how this would happen?

推荐答案

您必须使用广播接收器来接收意图,当你想简单的沟通做出适当的值的意图。

You have to use BroadcastReceiver to receive intents, and when you want to communicate simply make an Intent with appropriate values.

这样,你应该能够使任何组件之间的双向通信。

This way you should be able to make a 2-way communication between any component.

这篇关于两个服务之间的通信的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 16:26