0

I made a base application in Android Studio using Java. I did everything perfectly after login and register it opens the Main activity(connected with firebase for login) and I made a logout button in Main activity, so when I click on logout button, the activity switches to the login page we can see the login page but when I close the app and open it again, I am still at the main activity which means I am logged in what code I need to correctly logout a user and next time he opens shows the login page please answer me?

harsh tibrewal
  • 785
  • 6
  • 21
Abhiram
  • 145
  • 1
  • 1
  • 13

1 Answers1

1

You need to do two things 1 - launcher activity, you need to add your flow logic, like if a user is logged-in navigate to mainActivity, else, navigate to LoginActivity 1 - on logout logic, you need to clear the flag you used in launcher activity that tells the application that the user is logged-in or no, whatever logic you check by what the user is logged in or not, either shared preferences or you are based on google sign-in account, whatever you set, please base on it in the two places (logout, and launcher activity)