title: Android: Clear the back stack
body: <p>In Android I have some activities, let's say A, B, C.</p>
  
  <p>In A, I use this code to open B:</p>
  
  <pre><code>Intent intent = new Intent(this, B.class);
  startActivity(intent);
  </code></pre>
  
  <p>In B, I use this code to open C:</p>
  
  <pre><code>Intent intent = new Intent(this, C.class);
  startActivity(intent);
  </code></pre>
  
  <p>When the user taps a button in C, I want to go back to A and clear the back stack (close both B and C). So when the user use the back button B and C will not show up, I've been trying the following:</p>
  
  <pre><code>Intent intent = new Intent(this, A.class);
  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
  startActivity(intent);
  </code></pre>
  
  <p>But B and C are still showing up if I use the back button when I'm back in activity A. How can I avoid this?</p>