Exit/Finish an app/activity - android

Check out this link:

Click here

You can use :

@Override
public void onBackPressed()
{
     moveTaskToBack(true);
}

in all activities to close the app.


Use below code in your Act4'th Menu.xml's exit button -

Intent intent = new Intent(Act4.this, Act1.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("EXIT", true);
startActivity(intent);

And, in your first activity's onCreate() method just put the below code -

if (getIntent().getBooleanExtra("EXIT", false)) 
{
    finish();
}

This will exit your app.