title: 'boolean androidx.fragment.app.FragmentManagerImpl.isDestroyed()' on a null object reference
body: <p>I get this error crash</p>
  
  <pre><code>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method boolean androidx.fragment.app.FragmentManagerImpl.isDestroyed()' on a null object reference
  </code></pre>
  
  <p>When activity onStop() and when i remove fragment from FragmentTransaction</p>
  
  <p>i added </p>
  
  <pre><code>@Override
  public void onDetach() {
      super.onDetach();
  
      try {
          Field childFragmentManager = Fragment.class.getDeclaredField("mChildFragmentManager");
          childFragmentManager.setAccessible(true);
          childFragmentManager.set(this, null);
  
      } catch (NoSuchFieldException e) {
          throw new RuntimeException(e);
      } catch (IllegalAccessException e) {
          throw new RuntimeException(e);
      }
  }
  </code></pre>
  
  <p>to all my fragment, but it is not help</p>
  
  <p>My code</p>
  
  <pre><code>FragmentTransaction t = getSupportFragmentManager().beginTransaction();
                      //t.replace(R.id.calendar1, weekendCaldroidFragment);
                      t.detach(weekendCaldroidFragment).add(R.id.calendar1, weekendCaldroidFragment).attach(weekendCaldroidFragment).commitNowAllowingStateLoss();
  </code></pre>