title: open login activity when I press back button but i want to stop app android
body: <p>i have create a login activity when I logged in want to store login then i opened Main activity but when I press back button then i came to login activity.</p>
  
  <p>i want to stop app and when i press back button on Main activity.</p>
  
  <p>Again i opened my app, see login activity.</p>
  
  <p>I want to store login details in local and when i open app check credentials from local and open Main activity not login activity.</p>
  
  <p>please help me with description what you did ?</p>
  
  <p>My code</p>
  
  <pre><code>@Override
      protected void onPostExecute(String result) {
         String str = result.trim();
          if(str.equals("success")) {
              startActivity(new Intent(Login.this,MainActivity.class));
          }
          else{
              Toast.makeText(Login.this, "Either Username or Password is not correct", Toast.LENGTH_SHORT).show();
          }
          dialog.dismiss();
      }
  </code></pre>