title: 'IllegalStateException: Activity has been destroyed' when 'getSupportFragmentManager()' called after Activity restart
body: <p>I have a parent Fragment Activity that has a ViewPager which contains a child ViewPager. The child ViewPager contains Fragments for each page. I communicate between these child page fragments and the top parent Fragment Activity using a callback interface e.g.</p>
  
  <pre><code>public interface Callbacks {
      public void onItemSelected(Link link);
  }
  </code></pre>
  
  <p>In the parent Fragment Activity I listen for <code>onItemSelected</code> events e.g.</p>
  
  <pre><code>@Override
  public void onItemSelected(Link link) {
      Bundle argumentsFront = new Bundle();
      argumentsFront.putParcelable(FragmentComments.ARG_ITEM_ID, link);
      fragmentComments = new FragmentComments();
      fragmentComments.setArguments(argumentsFront);
      getSupportFragmentManager().beginTransaction().replace(R.id.post_container, fragmentComments).commitAllowingStateLoss();
  }
  </code></pre>
  
  <p>Now this works fine when the app is first launched.</p>
  
  <p>If you turn the device to change the orientation the Activity restarts. All fragments reinitialise themselves as I use <code>setRetainInstance(true);</code> (I do not call setRetainInstance(true) in the page Fragments of the child ViewPager as it is not supported). However if I click a list item in the Fragment of the child ViewPager I get this exception:</p>
  
  <pre><code>FATAL EXCEPTION: main
  java.lang.IllegalStateException: Activity has been destroyed
  at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1342)
  at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:595)
  at android.support.v4.app.BackStackRecord.commitAllowingStateLoss(BackStackRecord.java:578)
  </code></pre>
  
  <p>Does anyone know why this happens?</p>
  
  <p>Thanks</p>