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?
1
-
what are you trying to do with an application with two processes? The other answers are assuming that you want to do IPC, is that what you want to do? A process with one thread is what identifies an application, two processes are two applications? What is your intention for using two processes? (Are you just curious?)AntonioHL– AntonioHL2025-01-24 02:03:07 +00:00Commented Jan 24 at 2:03
Add a comment
|
2 Answers
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"/>
3 Comments
Marie
your answer and blog look good. I am accepting your answer and voting for it. If I need some clarification later I hope you will provide.
Jojje
The blog post link is dead, please fix it, as this is really interresting.
CopsOnRoad
Link shows some kind of lotteries. Please fix the link.
If you are looking for examples, do check out hogwarts library, it shall provide you facilities for multi-processes programming in Android.
Basically there are following things you need to have in order to run a service in its "own" process.
- in AndroidManifest.xml, make sure the service's process attribute is ":remote" or something like it with a ":" prefix
- use startService() calling to bring up the service from your activity.
- use AIDL for ipc.
- Make everything transfer between processes Parcelable. (this is actually the requirement for point 3)
1 Comment
AntonioHL
the URL is not found 404