4

I'm trying to understand the android:process attribute. Ref says:

If the name assigned to this attribute begins with a colon (':'), a new process, private to the application, is created when it's needed. If the process name begins with a lowercase character, a global process of that name is created. A global process can be shared with other applications, reducing resource usage.

Will a process be created if the name doesn't begin with a colon? What if it begins with a capital letter? And what happens if I mix the two rules?

I need to have two components from two packages run in the same process to save resources (and to avoid having two "running apps" listed in the apps manager). What should be my process name? Do I need a global process?

EDIT:

I tried with a simple lower case name (first package's name) and it seems it's working like I want. Still I think I don't get the rules.

2 Answers 2

8

And what happens if I mix the two rules?

That's not possible. A colon is not a capital letter.

I need to have two components from two packages run in the same process to save resources (and to avoid having two "running apps" listed in the apps manager).

That's really not a good idea. Put them in the same package, or have them run independently.

Not only would you have to mess around with android:process, but you also have to mess around with android:sharedUserId. Neither of these are meant to be used by ordinary SDK developers, particularly android:sharedUserId. In fact, if you have already distributed your application, you can't use android:sharedUserId unless you're willing to break all your existing users' apps, since you will no longer be able to access your original data, since it'll be owned by some other user account.

Furthermore, unless you have evidence to the contrary, I would not assume that this will somehow "avoid having two 'running apps' listed in the apps manager".

Now, I am all for efficiency, and so creating extra processes for grins (e.g., misguided advice to make "remote services" run in custom processes) is a bad idea. And if you work for a device manufacturer or a firm with 20+ Android developers or something, and you want to mess around with this, you're going to need to find places where it is used in the AOSP and reverse-engineer the information you seek, since this stuff is seriously under-documented. And even there, I am not seeing it used between multiple packages, except for android.process.acore and com.android.phone, which are seriously low-level processes and are not going to be typical of non-firmware apps.

Hence, I really recommend that you leave these things alone.

Sign up to request clarification or add additional context in comments.

Comments

0

i guess you are speaking about background services, right? If you start your service without the ":", the service is running the same process as your application does, in that case it's called a "local service". If you start it with the ":" it will run in its own process, called "remote service". In that case can be used maybe by other activities.

By default, Android creates a process for an application when the first of its components needs to run. All components then run in that process. The name of the default process matches the package name set by the element.

Seems you don't have to provide the android:process parameter, except you want to specify the name of your application process. And if you want some component of your application run inside a different process, as I described with the service example above.

hope that helps little bit. nyyrikki

4 Comments

"If you start it with the ":" it will run in its own process, called "remote service". In that case can be used maybe by other applications and activities." -- remote services do not need to run in their own process.
hm, okay. but for my understanding, what would be the difference between a let's call it local service (running in same process than the application, sharing heap and so on) and a "remote service" which isn't running inside it's own process as you said? thanks in advance for your help, nyyrikki
A remote service is exported and has an API designed for third parties to use (e.g., AIDL).
@CommonsWare could i comunicate between Application's process(eg. an Activity) and a Service(run on it's own process, android:process=":SelfProcess" ) using a Broadcast/BroadcastReceiver. what should i do? thanks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.