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
android:launchMode="singleTop"
to the activity element in your manifest for Activity Aintent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
and
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
when starting Activity AThis means that when Activity A is launched, all tasks on top of it are cleared so that A is top. A new back stack is created with A at the root, and using singleTop
ensures you only ever launch A once (since A is now on top due to ..._CLEAR_TOP
).