System.exit(0) doesnt close all my activities?
android, android-activity
Solution
Don't use `System.exit`.
If you want user to close app from any `Activity` I suggest using `startActivityForResult`, checking returned value in `onActivityResult` in first `Activity` and calling `finish()` there too.
Problem
I have 2 activity, so activity 1 go to activity 2 then on activity 2 I have an exit button. But when I click it, all it only exited the activity number 2 and return to activity 1 again. Its basically felt like I just started the application again. I am not sure why? This is my code. ``` Button btExit = (Button) findViewById(R.id.btExit); btExit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); System.exit(0); } }); ```