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?
Asked
Active
Viewed 138 times
0
-
You need to make sure the session is no longer valid after logout. – kutschkem Jan 14 '21 at 12:39
-
Does this answer your question? [Properly log out a user from android app](https://stackoverflow.com/questions/35541675/properly-log-out-a-user-from-android-app) – Sekiro Jan 14 '21 at 12:40
-
remove the store data from local or check the session is logout or not – Amit pandey Jan 14 '21 at 12:44
1 Answers
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)
Reda El-hadidy
- 21
- 3