code: @Override
      public void onDismiss(DialogInterface dialog) {
          if (mOldDialog != null && mOldDialog == dialog) {
              // This is the callback from the old progress dialog that was already dismissed before
              // the device orientation change, so just ignore it.
              return;
          }
          super.onDismiss(dialog);
      }
docs: There is a race condition that is not handled properly by the DialogFragment class.
  If we don't check that this onDismiss callback isn't for the old progress dialog from before
  the device orientation change, then this will cause the newly created dialog after the
  orientation change to be dismissed immediately.