title: Intent.FLAG_ACTIVITY_CLEAR_TOP not closing all activities in the stack in android
body: <p>I want to close all activities in th stack before going to new activity.</p>
  
  <p>this is my code</p>
  
  <pre><code>Intent i=new Intent(first.this,secondsct.class);
                          i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                          //i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                          //i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                          //i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                          startActivity(i);
                          finish();
  </code></pre>
  
  <p>But this is not working. I have tried this earlier but not now. I dont know why. Can anyone know what may be the reason.</p>