Start a service in a separate process android

Check out the process attribute for service in AndroidManifest.xml. You need to change your android:process value to start with a :.

http://developer.android.com/guide/topics/manifest/service-element.html

The relevant section:

If the name assigned to this attribute begins with a colon (‘:’), a new process, private to the application, is created when it’s needed and the service runs in that process. If the process name begins with a lowercase character, the service will run in a global process of that name, provided that it has permission to do so. This allows components in different applications to share a process, reducing resource usage.

The other answer provided doesn’t really answer the question of how to start a service in a separate process.


Defining a Process of a Service

The android:process field defines the name of the process where the service is to run. Normally, all components of an application run in the default process created for the application. However, a component can override the default with its own process attribute, allowing you to spread your application across multiple processes.

If the name assigned to this attribute begins with a colon (‘:’), the service will run in its own separate process.

<service
  android:name="com.example.appName"
  android:process=":externalProcess" />

If the process name begins with a lowercase character, the service will run in a global process of that name, provided that it has permission to do so. This allows components in different applications to share a process, reducing resource usage.

Leave a Comment