Exclude an activity from back-stack history

suggest change

Activity B can be opened and can start further activities. The user should return to the activity that opened B, skipping B, when navigating back.

The simplest solution is to set the attribute noHistory to true for that <activity> tag in AndroidManifest.xml:

<activity
     android:name=".B"
     android:noHistory="true" />

This same behavior is also possible from code if B calls finish() before starting the next activity:

finish();
startActivity(new Intent(context, C.class));

Typical usage of noHistory flag is with “Splash Screen” or Login Activities.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents