Hi!
So, I checked onAttachActivity and onDetach and this is very puzzling.
onAttach is called, I store the reference to the "activity", but onDetach
is not called, and when I try to call getActivity(), or reference the
stored activity, I always get null back.
So that is the reason FragmentManager is failing as well, only I don't know
why the activity is missing...?
If I dump the fragment manager, I see that the activity is there (see
emphasis):
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}
Any help or pointers on what to look for would be appreciated!
Thanks!
Miha
On Thursday, May 23, 2013 9:51:07 PM UTC+2, Miha wrote:
>
> Hi Streets Of Boston!
>
> On Thursday, May 23, 2013 4:16:22 PM UTC+2, Streets Of Boston wrote:
> > When using fragments inside a fragment, you should use the fragment's
> ChildFragmentManager and not the (activity's) main FragmentManager.
>
> You are right. It's working when using child fragment manager, but the
> "backstack" inside the child fragment manager is not working. For instance,
> I'm replacing fragments based on user interaction, and when I call
> popBackStackImmediate(), the runtime throws NullPointerException:
> android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1419)
>
> If I use popBackStack() instead of it's *Immediate sidekick, I get an
> IllegalStateException: Activity has been destroyed:
> android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1342)
>
> That was the reason I wen't with "activity's fragment manager" in the
> beginning...
>
> Any ideas what can be wrong? The "main" fragment in a viewpager inflates a
> layout with one "frame layout" inside. I'm addin child fragments to that
> frame layout, and calling addToBackStack(null) in the process.
>
> Regards,
> Miha.
>
>
>
>
>
>
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.