title: Close multiple activities on stack
body: <p>Found lots of similar questions but none that suited my situation.</p>
  
  <p>Basically I have an Android app that flows like so:</p>
  
  <pre><code>HOME &gt;&gt; CHECKOUT 1 &gt;&gt; CHECKOUT 2 &gt;&gt; CONFIRMATION PAGE
  </code></pre>
  
  <p>Once we get to the confirmation page I want to 'finish' both checkout pages as I don't want the user seeing orders that have been submitted if they were to hit the back button. I know how to finish the Checkout 2 page once I confirm the order but I don't know how to 'cascade' down the stack to finish both.</p>
  
  <p>When the user hits Back on the confirmation page they should go to the Home screen. I know how to do this with Intents but that's no good for the back button. Unless I override the back button behaviour and do something like:</p>
  
  <pre><code>Intent intent = new Intent(getApplicationContext(), Home.class);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  startActivity(intent);
  </code></pre>
  
  <p>But I feel like this is very hacky. Anyone know the proper way to do it? Some sort of session variable that <code>Checkout1.onResume</code> looks for maybe?</p>
  
  <p>Cheers</p>