如何Android应用程序有多个进程? [英] How can an Android application have more than one process?
问题描述
我已经开发了一个Android应用程序,有1流程和2服务。但我注意到,谷歌服务有2个进程和1服务。它如何能有2个进程?我做了一些读数进程和线程尝试了解更多有关进程。它谈论有一个清单条目,但没有一个具体的例子,我不明白这一点。有人可以解释一个Android应用程序如何有超过1的过程,并提供了一个具体的例子?
I have developed an Android application that has 1 process and 2 services. But I noticed that "Google Services" has 2 processes and 1 service. How can it have 2 processes? I did some reading at Processes and Threads to try to understand more about processes. It talks about having a manifest entry, but without a concrete example I don't get it. Can someone explain how an Android application can have more than 1 process and provide a concrete example of that?
推荐答案
您可以指定安卓程序=:远程
在你的清单中有一个活动/服务在一个单独的进程中运行。
You can specify android:process=":remote"
in your manifest to have an activity/service run in a seperate process.
远程是远程过程的只是名字,你可以调用它任何你想要的。如果你想几个活动/服务,在同一个进程中运行,只要给它相同的名称。
The "remote" is just the name of the remote process, and you can call it whatever you want. If you want several activities/services to run in the same process, just give it the same name.
<activity android:name=".RemoteActivity" android:label="@string/app_name" android:process=":RemoteActivityProcess"/>
我已经写博客文章而回解释属性,以及如何调试远程进程。
I've written a blog post a while back explaining the attribute, and how to debug the remote process.
这篇关于如何Android应用程序有多个进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!