从同一应用程序的不同进程启动本地服务

时间:2015-07-13 20:37:54

标签: android android-service

我在Android文档中找到了以下代码段。

 A service runs in the main thread of its hosting process...

 Note that calls to startService() are not nesting: no matter how many times you call startService(), a single call to stopService(Intent) will stop it.

我认为这意味着对startService()的多次调用不会导致服务的多个实例。

考虑以下情况:

我有一个名为MyApp的应用,其中包含两项服务:MyServiceMyRemoteService。在这里,MyService是本地服务,而顾名思义,MyRemoteService 在单独的流程中运行

如果我打电话给startService()MyService Activity开始MyApp,然后又从MyRemoteService开始,会怎样?

MyService会运行哪个进程?在两个不同的进程中是否会运行两个不同的MyService实例:一个在托管我的主Activity的进程中,另一个实例在托管MyRemoteService的进程中运行?在这种情况下,上述两个片段会如何支撑?任何帮助都感激不尽。感谢。

0 个答案:

没有答案