`
public void SignOut(View view) {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
}
`I have an android application. Activities are like -> A->B->C->D->E. Activity A have login page. So on moving to next activity, that is B, i don't finish activity A. Stack grows like: A,B,C,D then activity D is finished and E is started. In activity E, I have a sign out button. Till now my stack is: A,B,C,E. On pressing sign-out, E is popped out. I want to clear the activity stack at this point and want to start my first activity i.e. A which is asking for login. I can't achieve this. My stack becomes A,B,C,A after sign out. I want the stack to be A only. Please help. Thanks in advance.