title: Clear the entire history stack and start a new activity on Android
body: <p>Is it possible to start an activity on the stack, clearing the entire history before it?</p>
  
  <p><strong>The situation</strong></p>
  
  <p>I have an activity stack that either goes A->B->C or B->C (screen A selects the users token, but many users only have a single token). </p>
  
  <p>In screen C the user <em>may</em> take an action which makes screen B invalid, so the application wants to take them to screen A, regardless of whether it is already in the stack. Screen A should then be the only item on the stack in my application.</p>
  
  <p><strong>Notes</strong></p>
  
  <p>There are many other similar questions, but I haven't found anything that answers this exact question. I tried calling <code>getParent().finish()</code> - this always results in a null pointer exception. <code>FLAG_ACTIVITY_CLEAR_TOP</code> only works if the activity is already on the stack. </p>