I have two different activities. The first launches the second one. In the second activity, I call System.exit(0)
in order to force the application to close, bu
It is not recommended, but you can still use this. Better go with this solution in case you need to quit the app.
According to me, the best solution is to finish every activity in your app like below.
Step 1. Maintain a static variable in mainactivity. Say,
public static boolean isQuit = false;
Step 2. On click event of an button, set this variable to true.
mainactivity.isQuit = true;
finish();
Step 3. And in every activity of your application, have the onrestart
method as below.
@Override
protected void onRestart() {
// TODO Auto-generated method stub
super.onRestart();
if(mainactivity.isQuit)
finish();
}