Android Activity Exclude an activity from back-stack history


Let there be Activity B that can be opened, and can further start more Activities. But, user should not encounter it when navigating back in task activities.

Activity stack behavior

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


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

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

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