title: How to clear the stack on a SingleTop SingleInstance MainActivity on Android?
body: <p>I am trying to clear every single activity on the stack by <code>startActivity</code> method with the <code>Intent</code> flags:                      <code>(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY)</code></p>
  
  <p>(I have an exit button that resets and finishes all activities and I tried all "how to make an exit button, how to terminate an app" questions/answers. They don't help me because of the <code>singleInstance</code> <code>launchMode</code> configuration of <code>MainActivity</code>.</p>
  
  <p>Normally this should work and finish current activity automatically without calling <code>finish()</code>. However, as I marked MainActivity as <code>singleInstance</code> in the <code>AndroidManifest.xml</code>, it doesn't work. If I remove that <code>singleInstance</code>, it works as expected.</p>
  
  <p>If I call <code>finish()</code> manually right after/before launching the <code>MainActivity</code> to clear all the stack, <code>finish()</code>will return the app to the previous activity on the stack. But I already launched the <code>MainActivity</code>. So everything gets messed.</p>
  
  <p>(I tried adding <code>Intent.FLAG_ACTIVITY_SINGLE_TOP</code>and <code>Intent.FLAG_ACTIVITY_MULTIPLE_TASK</code> too just to see if it changes anything and it didn't)</p>
  
  <p>I need a solution which works with <code>singleInstance</code> and which does not require manual <code>finish()</code>.</p>
  
  <p><strong>Update 1: I try to launch this <code>Intent</code>from a <code>SingleTop</code> activity (but changing it changes nothing)</strong></p>
  
  <p><strong>Update 2: I try this on Android 2.3.3 emulator</strong></p>