title: FLAG_ACTIVITY_CLEAR_TOP does not work as expected
body: <p>I have 4 activities A, B, C, D, E with each declared as <code>android:launchMode="singleInstance"</code> and A being <code>parentActivity</code> of B, and B being parent Activity of C, in manifest.</p>
  
  <p>Now user navigated to E like this: A > B > C > D > E.
  And I have a button in E with the following onClickListener</p>
  
  <pre><code>    Intent intent = new Intent(E.this, C.class);
      intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      startActivity(intent);
  </code></pre>
  
  <p><strong>What I need?</strong> (Also according to documentation, if I understood it right, this should happen)</p>
  
  <ul>
  <li>Activities D and E should be cleared from stack</li>
  <li>Activity C should be resumed receiving the intent (as singleInstance is set, it will not be created newly)
  
  <blockquote>
    <p>I want this stack: C | B | A</p>
  </blockquote></li>
  </ul>
  
  <p><strong>What's happening?</strong></p>
  
  <ul>
  <li>Activity C is resumed receiving the intent</li>
  <li>Activities D and E are <strong>NOT</strong> cleared from stack. I can click back button again and again to see E, D, B, A.
  
  <blockquote>
    <p>I get this stack: C | E | D | B | A</p>
  </blockquote></li>
  </ul>
  
  <p>PS: My question is very similar to <a href="https://stackoverflow.com/questions/23718356/flag-activity-clear-top">this</a> however, the answers given there does not suit this question. Some answers I found there and elsewhere:</p>
  
  <ol>
  <li>I can't use NEW_TASK flag, as I need to keep A, B in stack alive.</li>
  <li>I can't use startActivityForResult() on D and then finish() it which in fact is a hack, as I have other decisive factors in E such as delivering the intent to some other activity depending on user input.</li>
  <li>I can't finish() activity D, while delivering intent to E, and then finish() E while hitting C, which would actually solve the problem. But, if back is pressed on E, i want it go back to D and not C.</li>
  <li>When I try finish() on E as soon as I do <code>startactivity(intent)</code> after setting flags, it just finishes E, but not D.</li>
  </ol>