Hi!

Starting a new topic 
from 
https://groups.google.com/forum/?fromgroups#!topic/android-developers/WgokX2uhv88;
 
I have a situation where I'm using ViewPager to flip between fragments, and 
two of the fragments have nested fragments.

Fragment nesting is done via getChildFragmentManager and orientation 
changes work as expected (fragments implement onSaveInstanceState), but 
when trying to pop the backstack after user interactions, I just get a 
NullPointerException or an "IllegalStateException: Activity has been 
destroyed" depending on whether I use popBackStack or popBackStackImmediate.

If I dump the child fragment state, it shows the activity as detached; If I 
dump the "parent" fragment manager state, it shows all of the fragments and 
also the activity reference (see below).

I'm using support library, and with that, I'm using classes from 
android.support.v4.app package.

Child fragment state:
FragmentManager misc state:
  mActivity=null
  mContainer=android.support.v4.app.Fragment$1@41603ca0
  mParent=MainFilesFragment{4169ccf0}
  mCurState=0 mStateSaved=false mDestroyed=false

Parent fragment state:
Active Fragments in 414896e0:
  #0: null
  #1: ConnectFragment{41505ae0 #1 id=0x7f060001}
    mFragmentId=#7f060001 mContainerId=#7f060001 mTag=null
    mState=5 mIndex=1 mWho=android:fragment:1 mBackStackNesting=0
    mAdded=true mRemoving=false mResumed=true mFromLayout=false 
mInLayout=false
    mHidden=false mDetached=false mMenuVisible=false mHasMenu=false
    mRetainInstance=false mRetaining=false mUserVisibleHint=false
    mFragmentManager=FragmentManager{414896e0 in MainActivity{41489470}}
    mActivity=com.islonline.isllightdesign.MainActivity@41489470
    mContainer=android.support.v4.view.ViewPager{4145c668 VFED.... ........ 
0,0-800,1033 #7f060001 app:id/pager}
    mView=android.support.v4.app.NoSaveStateFrameLayout{414b1258 V.E..... 
........ 800,0-1600,1033}
    mInnerView=android.support.v4.app.NoSaveStateFrameLayout{414b1258 
V.E..... ........ 800,0-1600,1033}
  #2: MainFilesFragment{4155a430 #2 id=0x7f060001}
    mFragmentId=#7f060001 mContainerId=#7f060001 mTag=null
    mState=5 mIndex=2 mWho=android:fragment:2 mBackStackNesting=0
    mAdded=true mRemoving=false mResumed=true mFromLayout=false 
mInLayout=false
    mHidden=false *mDetached=false* mMenuVisible=true mHasMenu=false
    mRetainInstance=false mRetaining=false mUserVisibleHint=true
    mFragmentManager=FragmentManager{414896e0 in MainActivity{41489470}}
    *mActivity=com.islonline.isllightdesign.MainActivity@41489470*
    mContainer=android.support.v4.view.ViewPager{4145c668 VFED.... ........ 
0,0-800,1033 #7f060001 app:id/pager}
    mView=android.support.v4.app.NoSaveStateFrameLayout{4155bcf8 V.E..... 
........ 1600,0-2400,1033}
    mInnerView=android.support.v4.app.NoSaveStateFrameLayout{4155bcf8 
V.E..... ........ 1600,0-2400,1033}
    Child FragmentManager{4155b598 in MainFilesFragment{4155a430}}:
      Active Fragments in 4155b598:
        #0: ComputerListFragment{4155b7b8 #0 id=0x7f060010 COMPUTER_LIST}
          mFragmentId=#7f060010 mContainerId=#7f060010 mTag=COMPUTER_LIST
          mState=1 mIndex=0 mWho=android:fragment:2:0 mBackStackNesting=1
          mAdded=false mRemoving=true mResumed=false mFromLayout=false 
mInLayout=false
          mHidden=false mDetached=false mMenuVisible=true mHasMenu=false
          mRetainInstance=false mRetaining=false mUserVisibleHint=true
          mFragmentManager=FragmentManager{4155b598 in 
MainFilesFragment{4155a430}}
          *mActivity=com.islonline.isllightdesign.MainActivity@41489470*
          mParentFragment=MainFilesFragment{4155a430 #2 id=0x7f060001}
          mSavedViewState=android.util.SparseArray@41690a60
        #1: FileShareBrowserFragment{41690840 #1 id=0x7f060010}
          mFragmentId=#7f060010 mContainerId=#7f060010 mTag=null
          mState=5 mIndex=1 mWho=android:fragment:2:1 mBackStackNesting=1
          mAdded=true mRemoving=false mResumed=true mFromLayout=false 
mInLayout=false
          mHidden=false mDetached=false mMenuVisible=true mHasMenu=false
          mRetainInstance=false mRetaining=false mUserVisibleHint=true
          mFragmentManager=FragmentManager{4155b598 in 
MainFilesFragment{4155a430}}
          *mActivity=com.islonline.isllightdesign.MainActivity@41489470*
          mParentFragment=MainFilesFragment{4155a430 #2 id=0x7f060001}
          mContainer=android.widget.FrameLayout{4155b210 V.E..... ........ 
0,0-800,1033 #7f060010 app:id/file_browser_container}
          mView=android.support.v4.app.NoSaveStateFrameLayout{41698148 
V.E..... ........ 0,0-800,1033}
          mInnerView=android.support.v4.app.NoSaveStateFrameLayout{41698148 
V.E..... ........ 0,0-800,1033}
        #2: null
      Added Fragments:
        #0: FileShareBrowserFragment{41690840 #1 id=0x7f060010}
      Back Stack:
        #0: BackStackEntry{41690780 #0}
          mName=null mIndex=0 mCommitted=true
          Operations:
            Op #0: REPLACE FileShareBrowserFragment{41690840 #1 
id=0x7f060010}
              Removed: ComputerListFragment{4155b7b8 #0 id=0x7f060010 
COMPUTER_LIST}
      Back Stack Indices:
        #0: BackStackEntry{41690780 #0}

Thanks,
 Miha.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to