Issue
I've made a login screen on Android.
After the client enters their name and password, they are directed to another screen via intent.
However, there is a problem after signing in and then pressing the back button on the phone to leave the app. When opening the application for a second time after doing so, it again returns to the login screen.
How can I prevent this from occurring so it does not repeatedly ask for login information?
Solution
Clear the task when calling the next activity:
Intent intent = new Intent(this, NextActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
This will clear the backstack and on pressing back, your application will close.
Answered By - Basant Singh