0

I'm developing an app which calls rest webservice for login.After the user has successfully logged in user is navigated to Main Menu and the corresponding UID and password is saved in local db.I want to navigate back to login screen after logout(Logout button is on main menu) .

Here's the logic that i've used for logout: I'm simply navigating back to login page after the logout button is pressed ,every time the user navigates back to main menu(by pressing return key) ,login credentials(that are stored in session)are matched.

So what i expect is that when a user logs out, the login credentials are deleted(i've also tried deleting it programatically) and when user presses return key(hard key) it closes the application.

Problem: After the logout button is pressed the app is navigated to login page but when i press the return key(hard key) the app navigates back to main menu Guys please help.New logic for logout are highly appriciated.Also can you tell me how to end the application process if i wanted to terminate the application when i press exit button on my app.(I've tried using system.exit(0)).

HyperioN
  • 3,433
  • 2
  • 22
  • 36

2 Answers2

1

See this answer Override back button to act like home button - it involves overriding the back button. Just change the "moveTaskToBack(true) to be a new intent, and start the new activity (login page)

Community
  • 1
  • 1
lcta0717
  • 402
  • 5
  • 13
0

You can add it to your login_menu class:

@Override
public void onBackPressed() {
    //Do nothing
}

It will desactivate the hard button and so, when the user will be back on this page, it won't be able to come back.

Underground72
  • 105
  • 2
  • 11