In the Activity login, just after the line that has startActivity()
put finish();
. This will close the Activity login making clicking on the back does not return to it and the application is closed.
Anything like this:
Intent intent = new Intent(MainActivity.this, Main2Activity.class);
startActivity(intent);
finish();
The same can be achieved by intent flags :
Intent intent = new Intent(MainActivity.this, Main2Activity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
However, since there is only one Activity in the Stack, it is best to use the first method.