How to clear backstack of a task and leave only the new activity?
<p>I want to clear the backstack when I start new Activity intent.</p>

<p>The exact case of my problem is as following:
I have activities like this A > B > C > D > E
"A" is a registration activity and "B" is a confirm registration activity.  I want that when user start activity "B" that he can't back to activity "A" anymore, also when user reach activity "C", both activity "A" and "B" would be useless, I don't need user back to them anymore.</p>

<p>Also when user moves to activity "D" from "C", he can get back to "C" but if he moved further to "E" activity, he can't get back to any of the previous "C" or "D" activities.</p>

<p>After a lot of research, the best I got is to use flag: <a href="http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_NO_HISTORY" rel="nofollow">FLAG_ACTIVITY_NO_HISTORY</a>, But it has two problems for my case:</p>

<ol>
<li>At activity "A" if user navigate away from my application (for example to home screen), it destroy that activity and hence all information that user entered is lost!</li>
<li>Activity "C" I want keep it in history (backstack) if while user navigate to "D" activity but when user move to "E" activity I want remove it.</li>
</ol>

<p>I can't find a solution for this problem till now, I think it would be easier if there something to clear the backstack of current task!</p>

<p>My minimum SDK support is 5.</p>

<p>Thanks in advance.</p>
