title: Android calling Dialog.show() directly after dismissing another dialog freezes app
body: <p>I'm trying to display a dialog directly after dismissing another one.</p>
  
  <pre><code>@Override
  public void onLoginFailure(Exception e, boolean ttl) {
      if(DialogUtils.isDialogShowing()){
          //dismisses progress dialog
          DialogUtils.DIALOG.dismiss();
      }
      DialogUtils.showExceptionDialog(this, "TTL Expired.");
  }
  </code></pre>
  
  <p>DialogUtils.java:</p>
  
  <pre><code>public volatile static Dialog DIALOG;
  
  public static boolean isDialogShowing() {
      return (DIALOG!=null &amp;&amp; DIALOG.isShowing());
  }
  
  public static Dialog showExceptionDialog(final Context ctx, final String message) {
      AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
      builder.setTitle(R.string.exception_title);
      builder.setMessage(message);
      builder.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialogInterface, int i) {
              dialogInterface.cancel();
          }
      });
      if(isDialogShowing()) {
          DIALOG.dismiss();
      }
      DIALOG = builder.create();
      DIALOG.show();
      return DIALOG;
  }
  
  public static Dialog showLoggingInProgressDialog(final Context ctx, final boolean cancellable) {
      AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
      builder.setCancelable(cancellable);
      builder.setTitle(R.string.dialog_login_title);
      //ProgressBar pb = new ProgressBar(ctx);
      //pb.setIndeterminate(true);
      //builder.setView(pb);
      if(isDialogShowing()) {
          DIALOG.dismiss();
      }
      DIALOG = builder.create();
      DIALOG.show();
      return DIALOG;
  }
  </code></pre>
  
  <p>In this code, when onLoginFailure is invoked, a "Logging in..." progress dialog is being displayed.  I try to dismiss that dialog to display an error dialog, but calling .show() on the new dialog freezes the app.  What am I doing wrong?</p>
  
  <p>UPDATE(12/16/13 8:53):
  changing the action to take on failure doesn't freeze the app, but the Toast text is never displayed...?</p>
  
  <pre><code>@Override
  public void onLoginFailure(Exception e, boolean ttl) {
      if(DialogUtils.isDialogShowing()){
          DialogUtils.DIALOG.dismiss();
      }
      if(ttl)
          //DialogUtils.showExceptionDialog(this, "TTL Expired.");
          Toast.makeText(this, "Login failed:\nTTL Expired...", Toast.LENGTH_SHORT);
      else if(e!=null)
          //DialogUtils.showExceptionDialog(this, e);
          Toast.makeText(this, "Login failed:\n" + e.getMessage(), Toast.LENGTH_SHORT);
  }
  </code></pre>