title: NullPointerException: Attempt to invoke virtual method 'android.app.FragmentTransaction android.app.FragmentManager.beginTransaction()'
body: <p>When I try to dissmiss a FragmentDialog, my app crashes sometimes.<br>
  Here's the log:</p>
  
  <pre><code>Process: com.xxx, PID: 9981
  java.lang.RuntimeException: Error receiving broadcast Intent { act=xxxx flg=0x10 (has extras) } in xxxxxx
      at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:893)
      at android.os.Handler.handleCallback(Handler.java:739)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:5438)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.FragmentTransaction android.app.FragmentManager.beginTransaction()' on a null object reference
      at android.app.DialogFragment.dismissInternal(DialogFragment.java:296)
      at android.app.DialogFragment.dismissAllowingStateLoss(DialogFragment.java:277)
      at xxxxx.updateStatus(BaseAppCompatActivity.java:96)
      at xxxxx.access$000(BaseAppCompatActivity.java:43)
      at xxxxx$1.onReceive(BaseAppCompatActivity.java:79)
      at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:883)
  </code></pre>
  
  <p>xxxxx.updateStatus(BaseAppCompatActivity.java:96)<br>
  this line is try to dismiss a DialogFragment:</p>
  
  <pre><code>mDialogFragment.dismissAllowingStateLoss();
  </code></pre>
  
  <p><br>
  A DialogFragment is in my Activity.<br></p>
  
  <pre><code>private SimpleBlockedDialogFragment mDialogFragment = SimpleBlockedDialogFragment.newInstance();
  </code></pre>
  
  <p>So mDialogFragment is not null.</p>
  
  <p>I show dialog like this:</p>
  
  <pre><code>FragmentTransaction ft = getFragmentManager().beginTransaction();
  mDialogFragment.updateMessage("xxx");
  mDialogFragment.show(ft, "block_dialog");
  </code></pre>
  
  <p>And dismiss dialog like this:</p>
  
  <pre><code>mDialogFragment.dismissAllowingStateLoss();
  </code></pre>
  
  <p>Sometimes, I show dialog only once, but dismiss more than once. But I don't think that cause a crash.</p>
  
  <p>Here's the dismissInternal function in the DialogFragment:</p>
  
  <pre><code>void dismissInternal(boolean allowStateLoss) {
      if (mDismissed) {
          return;
      }
      mDismissed = true;
      mShownByMe = false;
      if (mDialog != null) {
          mDialog.dismiss();
          mDialog = null;
      }
      mViewDestroyed = true;
      if (mBackStackId &gt;= 0) {
          getFragmentManager().popBackStack(mBackStackId,
                  FragmentManager.POP_BACK_STACK_INCLUSIVE);
          mBackStackId = -1;
      } else {
          FragmentTransaction ft = getFragmentManager().beginTransaction();
          ft.remove(this);
          if (allowStateLoss) {
              ft.commitAllowingStateLoss();
          } else {
              ft.commit();
          }
      }
  }
  </code></pre>
  
  <p>log tells me that getFragmentManager() return null. I don't know why this happened.<br>
  How to dismiss a FragmentDialog correctly?<br></p>
  
  <p><strong>update:</strong><br>
  I try android.support.v4.app.FragmentTransaction, and still get an exception.</p>
  
  <pre><code>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.FragmentTransaction android.support.v4.app.FragmentManager.beginTransaction()' on a null object reference
      at android.support.v4.app.DialogFragment.dismissInternal(DialogFragment.java:196)
      at android.support.v4.app.DialogFragment.dismissAllowingStateLoss(DialogFragment.java:177)
  </code></pre>
  
  <p>Help~</p>