难道一个服务绑定另一个服务 [英] Could a service bind another service
问题描述
我只是想知道我可以结合从其他服务的服务。例如,目前我有一个活动A
启动服务B
现在我只想服务B
来结合并启动另一个服务C
。因此,没有任何人知道该怎么做?这意味着我可以用同样的方法对活动A
来在服务启动服务启动另一个服务?
I just want to know could I bind a service from another service. For example, currently I have an activity A
starting a service B
and now I just want service B
to bind and start another service C
. So does anybody know how to do that? That means could I use the same method for activity A
to start a service on a service to start another service?
推荐答案
您可以拨打<一个href="http://developer.android.com/reference/android/content/Context.html#bindService%28android.content.Intent,%20android.content.ServiceConnection,%20int%29"><$c$c>bindService$c$c>从服务完全相同的方式,你可以从一个活动调用它。你会发现从唯一的地方,你不能叫 bindService
是一个的BroadcastReceiver
的Javadoc。您可以使用 ServiceConnection
以及接收文件夹
。
You can call bindService
from a Service exactly the same way you can call it from an Activity. You'll notice from the javadoc that the only place you can't call bindService
is in a BroadcastReceiver
. You can use a ServiceConnection
as well to receive the Binder
.
这篇关于难道一个服务绑定另一个服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!