Supposing I have an Activity Stack like this(from top to bottom):
D - C - B - A
So the activity D is on top of the stack and is currently running (displayed).
Now, from the activity D I want call the activity B (in the second position in the stack), so:
Intent intent = new Intent(this, ActivityB.class);
startActivity(intent);
After this operation, the new configuration of the stack, now should be:
B - D - C - B - A
But what I really want is the following stack configuration:
B - A
How can I obtain this result? Is there any FLAG that I can use for this?
Summarizing I want that when I start the activity B (from D) both D and C are automatically finished.