See this:
https://stackoverflow.com/a/6567878/850347
You can make more than one process by using setting below.
android:process=":remote"
Edit1
Alright.
Step1: Make app that has one local process, one global process.
AndroidManifest.xml Note that Setting capital letter for process name makes local process, and small letter process name makes global process.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kou.processtest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
<application>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LocalProcessActivity"
android:process=":Local1" />
<activity
android:name=".GlobalProcessActivity"
android:process=".global1" />
</application>
</manifest>
MainActivity.java
package com.kou.processtest;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
((Button) findViewById(R.id.btn1)).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, GlobalProcessActivity.class);
startActivity(intent);
}
});
}
}
GlobalProcessActivity.java
package com.kou.processtest;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class GlobalProcessActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_global_process);
((Button) findViewById(R.id.btn1)).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(GlobalProcessActivity.this, LocalProcessActivity.class);
startActivity(intent);
}
});
}
}
LocalProcessActivity.java
package com.kou.processtest;
import android.app.Activity;
import android.os.Bundle;
public class LocalProcessActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_local_process);
}
}
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${packageName}.${activityClass}" >
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="run global process" />
</RelativeLayout>
activity_global_process.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${packageName}.${activityClass}" >
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="run local process" />
</RelativeLayout>
activity_local_process.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${packageName}.${activityClass}" >
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="nothing" />
</RelativeLayout>
Step2: Run app. press button to run global process activity, and local process activity.
Step3: Check process by adb shell, ps. You can see the three processes.
C:\>adb shell ps
u0_a678 19654 2019 553956 33848 ffffffff 00000000 S com.kou.processtest
u0_a678 19680 2019 553952 34008 ffffffff 00000000 S .global1
u0_a678 19701 2019 558020 33588 ffffffff 00000000 S com.kou.processtest:Local1
Step4: Kill application on Setting menu.
Setting - App - App info - Force stop
Step5: Run ps again.
Result: all process was killed.
com.kou.processtest and .global1 and com.kou.processtest:Local1 was all killed.