title: Android - problems using FragmentActivity + Loader to update FragmentStatePagerAdapter
body: <p>I'm trying to use <code>FragmentActivity</code> with <code>ViewPager</code> to display dynamic list of <code>Fragments</code>. There are plenty of examples on how to do a static version of it. My problem is that the list I display needs to be loaded dynamically and also can change based on user input (add/delete). I'm trying to use customized <code>android.support.v4.content.Loader</code> to load set of data that I can use to build my list. </p>
  
  <p>Everything goes fine in my setup until I get to the point when I want to update the adapter and issue <code>FragmentStatePagerAdapter#notifyDataSetChanged()</code> call at which point this code is executed (from <code>FragmentStatePagerAdapter</code>)</p>
  
  <pre><code>public void finishUpdate(View container)
  {
      if(mCurTransaction != null)
      {
          mCurTransaction.commit(); // BANG!!! The exception is thrown
          mCurTransaction = null;
          mFragmentManager.executePendingTransactions();
      }
  }
  </code></pre>
  
  <p>The transaction commit fails with this message:</p>
  
  <p><code>java.lang.IllegalStateException: Can not perform this action inside of onLoadFinished</code></p>
  
  <p>because within <code>FragmentManagerImpl</code> this code is executed:</p>
  
  <pre><code>private void checkStateLoss() {
      if (mStateSaved) {
          throw new IllegalStateException(
                  "Can not perform this action after onSaveInstanceState");
      }
      if (mNoTransactionsBecause != null) {
          throw new IllegalStateException(
                  "Can not perform this action inside of " + mNoTransactionsBecause);
      }
  }
  </code></pre>
  
  <p>It turns out that <code>mNoTransactionsBecause</code> value is not null and it is set in <code>LoaderManagerImpl.LoaderInfo</code> when the result is returned back to <code>onLoadFinished</code></p>
  
  <p>I was looking at the various variables trying to somehow change <code>tramsaction.commit()</code> to <code>transaction.commitAllowingStateLoss()</code> but everything related to transaction seems to be private or at least package-protected.</p>
  
  <p>Can someone give me a general idea if I can do what I need to do (and how)? </p>
  
  <p>Just to note that my code works fine if instead of using Loader I run the loading ops in AsyncTask</p>