In Android I have some activities, let\'s say A, B, C.
In A, I use this code to open B:
Intent intent = new Intent(this, B.class);
startActivity(inte
I tried all solutions and none worked individually for me. My Solution is :
Declare Activity A as SingleTop by using [android:launchMode="singleTop"] in Android manifest.
Now add the following flags while launching A from anywhere. It will clear the stack.
Intent in = new Intent(mContext, A.class);
in.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK );
startActivity(in);
finish();