title: Clear Activity Stack and start new activity in android
body: <p>My question is little bit different than these type of question. I need to remove or clear my activity stack then start a new activity. I don't think it is a clear_top flag problem. I am explaining with an example:</p>
  
  <p>My Activity flow :</p>
  
  <pre><code>Login &gt; Home &gt; Screen1 &gt; screen2 ....
  </code></pre>
  
  <p>I finish Login activity or call with no_history flag. So my activities are look like this</p>
  
  <pre><code>Login(finished)&gt; Home [bottom of the stack now] &gt; Screen1 &gt; Screen2[top of the stack]
  </code></pre>
  
  <p>I need to handle session error. If any session error occurs in any point i need to go back to login activity. But remember i don't have login activity in stack. So clear_top will not work.</p>
  
  <p>If any session error occurs in Screen2 then i need to clear full stack (screen2, screen1, home) and then start login activity. So that after back button press in login activity will close my apps. </p>
  
  <p>Is there any way to clear the activity stack?</p>
  
  <p>thanks in advance</p>