CrazyCoder
CrazyCoder

Reputation: 2605

Android - keeping the service alive even parent process is killed

I am new to Android. Right now I am just trying some examples which includes Services. In one of the example, service is created as a separate background process. Using something like this

android:process=":background"  

They said now service will be having separate process environment and thus it is separate from the one(Application) that is started it. When I killed the parent process i.e.Application, the service is also getting killed. Is this normal behavior or not? Because what I understand from that article is Service wont get affected since it is different process environment. Please correct me if I am wrong. Thanks in advance

UPDATE: Even I saw the same behavior if I use :remote.

Upvotes: 6

Views: 2148

Answers (2)

AAnkit
AAnkit

Reputation: 27549

Afaik, there are two types of services,

1) background : which run in the same process of your application.

2) Remote :If we want to make this service run in a remote process (instead of the standard one for its .apk), we can use android:process in its manifest tag to specify one: ,

we can also use other strings then background and remote. here is service lifecycle

Upvotes: 1

Jammy Lee
Jammy Lee

Reputation: 1516

Just a copy from the Android document:

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

http://developer.android.com/guide/topics/manifest/application-element.html#proc

Upvotes: 1

Related Questions