I have an app with two processes. The second process starts when an Activity is created. Find below an excerpt of that Activity in the Manifest:
<activity
android:name=".ActivityInAnotherProcess"
android:process=":anotherprocess"
android:launchMode="singleTask"
...
After the ":anotherprocess" starts I need to kill the main process somehow, through the adb, in code, however.
I've tried "Terminate Application" in the DDMS and the main process is killed but recreated after a few seconds.
I've tried this code:
String packageName = c.getPackageName();
ActivityManager activityManager = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.killBackgroundProcesses(packageName);
but the main process is killed only to be recreated after a few seconds.
UPDATE: The code posted above works. I was calling it a few seconds after starting the Activity in the other process but it seems the other process was not fully started before I killed the main process. Now I'm killing the main process from the other process. This works now. Thanks all!