Im currently developing an application for android, the first screen of the application is the LoginActivity, it is authenticating with facebook and a facebook login dialog is shown on users request. The whole login process is working great, when you have logged in user are brought to a new activity. I’ve created a logout function in that activity which logging the user out of facebook in the whole application, but. If you press the “back-button” on an android device when the user is at the activity where you are when you have logged in the loginactivity is shown for the user. I want to make it impossible for the user to show the loginactivity but i don’t know how. When the user successfully logging in from the beggining the following lines are runned:
Intent intent = new Intent().setClass(LoginActivity.this, LocationActivity.class);
startActivity(intent);
And when the user successfully logged out from the MainActivity the following lines are runed:
ApplicationController appController = (ApplicationController)getApplicationContext();
appController.setfullnametoNull();
appController.setuseridtoNull();
finish();
Any suggestions on how to make it impossible for the user to get to the loginactivity when the user is currently logged in?
finish()the activity and if the user navigates to other app withoutlog outthen you shouldcheck in the login activitywhen comes back to app and redirect the user toappropriate activity. You need to save thelogin credentialsfor this. You can useSharedPreferencesfor this.