Note that there are some explanatory texts on larger screens.

plurals
  1. POIllegalStateException: <MyFragment> is not currently in the FragmentManager
    primarykey
    data
    text
    <p>I know it sounds like a duplicate of <a href="https://stackoverflow.com/questions/11296411/fragmentstatepageradapter-illegalstateexception-myfragment-is-not-currently">FragmentStatePagerAdapter IllegalStateException: &lt;MyFragment&gt; is not currently in the FragmentManager</a> but his solution isn't relevant to my case.</p> <p>I'm getting the following crash very rarely:</p> <blockquote> <p>java.lang.RuntimeException: Unable to pause activity {MyActivity}: </p> <p>...</p> <p>Caused by: java.lang.IllegalStateException: Fragment MyFragment {40648258 id=0x7f070051} is not currently in the FragmentManager at android.support.v4.app.FragmentManagerImpl.putFragment(MT:516) at android.support.v4.app.FragmentStatePagerAdapter.saveState(MT:185) at android.support.v4.view.ViewPager.onSaveInstanceState(MT:881) </p> <p>...</p> <p>at android.view.View.saveHierarchyState(View.java:6238) at com.android.internal.policy.impl.PhoneWindow.saveHierarchyState(PhoneWindow.java:1522) at android.app.Activity.onSaveInstanceState(Activity.java:1138) at android.support.v4.app.FragmentActivity.onSaveInstanceState(MT:480) at MyActivity.onSaveInstanceState(MT:336)</p> </blockquote> <p>It seems like this is the weird code I can't understand from <code>FragmentStatePagerAdapter</code>:</p> <pre><code>for (int i=0; i&lt;mFragments.size(); i++) { Fragment f = mFragments.get(i); if (f != null) { if (state == null) { state = new Bundle(); } String key = "f" + i; mFragmentManager.putFragment(state, key, f); } } </code></pre> <p>It looks like the adapter gets my <code>Fragment</code> from <code>mFragments</code> but can't add its state to <code>FragmentManager</code>.</p> <p>I've couldn't find any way to recreate this on my test devices, only received this from some users.</p> <p>I'm using support package v4.</p> <p>Any help? Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload