I have two actions, the first action is launched by Launcher, the second - by the first. When I kill a process from the first activity, the process is killed. But when I kill him because of the second action, the system will immediately start a new process and the first action. (Changed the PID of the process.) How can I do this cleanly?
I tried 3 different ways to kill the process: System.exit (0), android.os.Process.killProcess (pid) and non-programmatically from the Eclipse Devices panel.
Below are two of the simplest things in the world that I experimented with. Both are external classes in their respective files.
public class FirstActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
((Button)findViewById(R.id.button)).setOnClickListener(
new OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(FirstActivity.this,
SecondActivity.class));
}});
}
}
public class SecondActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_2);
((Button)findViewById(R.id.button)).setOnClickListener(
new OnClickListener() {
public void onClick(View v) {
int pid = android.os.Process.myPid();
android.os.Process.killProcess(pid);
System.exit(0);
}});
}
}
( , , , . , . )