アプリでかなりの ViewPager/FragmentStatePagerAdapter が動作していましたが、手動で Fragment を FragmentManager に追加した後、画面を TWICE 回転させるとこの例外が発生し始めました。
スタックトレース:
07-29 19:10:22.360: E/FragmentManager(712): Fragement no longer exists for key f0: index 1
07-29 19:10:22.360: E/FragmentManager(712): Activity state:
07-29 19:10:22.407: D/FragmentManager(712): Active Fragments in 4608be98:
07-29 19:10:22.410: D/FragmentManager(712): #0: RESTFragment{46005fb0 #0 RESTFragment}
07-29 19:10:22.410: D/FragmentManager(712): mFragmentId=#0 mContainerId=#0 mTag=RESTFragment
07-29 19:10:22.410: D/FragmentManager(712): mState=5 mIndex=0 mWho=android:fragment:0 mBackStackNesting=0
07-29 19:10:22.410: D/FragmentManager(712): mAdded=true mRemoving=false mResumed=true mFromLayout=false mInLayout=false
07-29 19:10:22.410: D/FragmentManager(712): mHidden=false mDetached=false mMenuVisible=true mHasMenu=false
07-29 19:10:22.419: D/FragmentManager(712): mRetainInstance=true mRetaining=false mUserVisibleHint=true
07-29 19:10:22.419: D/FragmentManager(712): mFragmentManager=FragmentManager{45fbe180 in MyActivity{46016180}}
07-29 19:10:22.419: D/FragmentManager(712): mActivity=com.argeniss.theguymob.frontend.MyActivity@46016180
07-29 19:10:22.419: D/FragmentManager(712): #1: null
07-29 19:10:22.419: D/FragmentManager(712): Added Fragments:
07-29 19:10:22.419: D/FragmentManager(712): #0: RESTFragment{46005fb0 #0 RESTFragment}
07-29 19:10:22.419: D/FragmentManager(712): #1: MyPageFragment{46024658}
07-29 19:10:22.419: D/FragmentManager(712): FragmentManager misc state:
07-29 19:10:22.419: D/FragmentManager(712): mActivity=null
07-29 19:10:22.419: D/FragmentManager(712): mContainer=null
07-29 19:10:22.430: D/FragmentManager(712): mCurState=0 mStateSaved=true mDestroyed=true
07-29 19:10:22.430: D/FragmentManager(712): mAvailIndices: [1]
07-29 19:10:22.430: E/com.argeniss.theguymob.frontend.MyActivity(712): Fragement no longer exists for key f0: index 1
これは、フラグメントをマネージャーに手動で追加するコードです。
private void addFragmentToManager() {
String fragmentTag = RESTFragment.TAG;
FragmentManager fragmentManager = getSupportFragmentManager();
restFragment = (RESTFragment) fragmentManager.findFragmentByTag(fragmentTag);
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
if (restFragment == null) {
restFragment = new RESTFragment();
fragmentTransaction.add(restFragment, fragmentTag);
}
// Adds the transaction to the fragment manager.
fragmentTransaction.commit();
fragmentManager.executePendingTransactions();
}