Reputation: 3
I have a login screen (activity), sign up (activity) and then a main (fragment) that a user needs to initially go through in order to enter the application. When the app is first loaded the user is presented with the login screen, if there is no user created yet they are brought to the sign up screen where they enter some information and set a password, once completed they are brought to the main screen where they can begin using the app. Right now when they make it to the main screen after signing up and press the back button they are brought back to the sign up screen where the information they last entered is still visible, I am wondering if there is a way to control the back button press event at the main screen so that it instead will always bring them back to the original login screen.
Anyone have any ideas ?
Thanks
Upvotes: 0
Views: 187
Reputation: 1522
You can finish your signup Activity before starting new activity. And handle onBackpressed() method in FragmentActivity.
Upvotes: 2
Reputation: 2258
Try this
@Override
public void onBackPressed() {
super.onBackPressed();
Intent intent = new intent(MainActivity.this, LoginActivity.class);
startActivity(intent);
}
Upvotes: 0