title: How to close app using exit and back button
body: <p>In my app I have menu page that contains 4 buttons History, Types, Benefits and Exit. After Splash Screen menu page opens. If I start History, Type or Benefit activity. I am not finish menu activity because if I finish this then on press on navigating up icon in action bar app close. When I am in any of the 3 activities and press device back button then I came back to menu activity. And if then I press exit or back button from device. EndSplash starts and app finish thats I want. But after one second app restart. How to close app on exit and back button?</p>
  
  <p>I also have navigating tabs below action bar. Minimum API level 8.</p>
  
  <p>In menu activity-</p>
  
  <pre><code>exit = (Button) findViewById(R.id.exit);
          exit.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View arg0) {
                  i = new Intent(MainActivity.this, EndSplash.class);
                      i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
                  startActivity(i);
                  finish();
              }
          });
  @Override 
      public void onBackPressed() {
          super.onBackPressed();
          i = new Intent(MainActivity.this, EndSplash.class);
          i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
          startActivity(i);
          finish();
      } 
  </code></pre>
  
  <p>And in History,Types and Benefits Activity-</p>
  
  <pre><code>public void onBackPressed()  
      {    
      startActivity(new Intent(this, MainActivity.class));  
          finish();
      }
  </code></pre>