I have a LoginActivity that checks SharedPreferences for login details, then redirects to HomeActivity and other actions after that. I placed the βExitβ menu item in each of these actions and used this code on the exit button.
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
How to hide login activity, so when the user clicks the "Back" button on the main screen, he will close the application.
As when opening the application, it shows the initial screen, and when I click the button, I usually close the application. But in my case, it takes me to the login screen, which is the first screen that checks the user credentials.
I cannot end the login activity, otherwise this solution will not work.
I am new to Android. Please suggest something to solve this problem.
source share