Login > HomePage ->Activity1 ->Activity2->Activity3
If once I have gone to Activity3 then from there to Home page. From there i am trying to logout. It is sending me back to the Login page but if I am pressing the back button of my phone it it showing all the previous activities. Please help me on how can we do this.
This is what i have tried
logout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
SharedPreferences myPrefs = getSharedPreferences("SelfTrip", MODE_PRIVATE);
SharedPreferences.Editor editor = myPrefs.edit();
editor.clear();
editor.commit();
Log.d(TAG, "Now log out and start the activity login");
Intent loginPageIntent = new Intent(getApplicationContext(), LoginPage.class);
loginPageIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
loginPageIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(loginPageIntent);
}
});