title: Can't get my app to close when YES is hit on Close dialog
body: <p>When the dialog box appears asking to close and "YES" is selected the app doesn't close but it looks like it does.  It looks like it might be closing the screen but not the actual app.  This is from the MainActivity.java.  Any ideas or recommendations?</p>
  
  <pre><code>private void showAlerExit() {
      {
          AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                  this);
  
          alertDialogBuilder
                  .setMessage("Are you sure you want to quit?")
                  .setCancelable(false)
                  // button yes
                  .setPositiveButton("Yes",
                          new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog,
                                      int id) {
                                  // if this button is clicked, close
                                  // current activity
                                  MainActivity.this.finish();
  
                              }
                          })
                  // button no
                  .setNegativeButton("No",
                          new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog,
                                      int id) {
                                  // if this button is clicked, just close
                                  // the dialog box and do nothing
                                  dialog.cancel();
                              }
                          });
  
          // create alert dialog
          AlertDialog alertDialog = alertDialogBuilder.create();
  
          // show it
          alertDialog.show();
      }
  
  }
  </code></pre>