title: How to remove activity from backstack in android?
body: <p>I have an app in which i have three activity namely:- Login,MainActivity and password activity.when I go to password activity and do some event then after login activity comes and here when i press back it will remove login and Mainactivity comes which I don't want. what i want when i press device back twice it will simple close app not to come Mainactivity.How can I archeive this problem.</p>
  
  <p>code that i have tried but not success.</p>
  
  <p>Login code:-</p>
  
  <pre><code>@Override
  protected void onResume() {
      super.onResume();
      clearAllTask();
  }
  
  private void clearAllTask() {
      CMainActivity m_MainActivity = new CMainActivity();
      if (m_MainActivity.m_MainActivity != null) {
          m_MainActivity.m_MainActivity.finish();
      }
  
  }
  </code></pre>
  
  <p>and code for MainActivity</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      m_MainActivity = this;
  }
  </code></pre>