title: Android popping activities off the stack - yes, again
body: <p>I have an app that starts a sequence of dialog-themed activities and I want to be able to pop them all off at once and go back to the main activity. I looked over existing questions like:</p>
  
  <p><a href="https://stackoverflow.com/questions/3338841/how-to-clear-current-activities-in-the-stack">How to clear current activities in the stack?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/3408388/how-to-kill-sub-activities-and-bring-activity-to-top-of-stack">how to kill sub activities and bring activity to top of stack</a></p>
  
  <p><a href="https://stackoverflow.com/questions/3517063/android-popping-off-the-activity-stack">Android Popping off the Activity Stack</a></p>
  
  <p>And based on that came up with this: </p>
  
  <pre><code>Intent intent = new Intent(this, MainActivity.class);
  intent.setFlags(android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP);
  startActivity(intent);
  </code></pre>
  
  <p>This works functionally, but the problem I have is that when this is executed, the screen behind the dialog-themed activity turns black for a second before finally animating the dialogs off the screen. If I pop these activities manually with a back button this does not happen. </p>
  
  <p>In LogCat I can see that when I pop the dialogs using the <code>Intent</code> method above, the main activity is destroyed and re-created, whereas when I just use the back button, the <code>onDestroy</code> and <code>onCreate</code> methods do not run. Is there any way to prevent the main activity from being explicitly re-started this way? </p>