When i am clicking on Logout button in my Profile Activity i want to take user to Login page, where he needs to use new credentials.
Hence i used this code:
Intent intent = new Intent(ProfileActivity.this,
LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
in the onButtonClick
of the Logout button.
But the problem is when i click device back button on the Login Activity it takes me to the ProfileActivity. I was expecting the application should close when i press device back button on LoginActivity.
What am i doing wrong?
I also added android:launchMode="singleTop"
in the manifest for my LoginActivity
Thank You
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
I got the answer from this question: stackoverflow.com/questions/3473168/… – jokeefe