Why is Android O failing with “does not belong to this FragmentManager!”

前端 未结 8 2394
深忆病人
深忆病人 2020-12-08 10:23

I have migrated my application to Android O in Android Studio 3

Running on an Android O emulator all my dialogFragments now fail with :-

java.lang.I         


        
8条回答
  •  萌比男神i
    2020-12-08 10:47

    I had the same case as Markus Ressel but I was using getChildFragmentManager(). I replaced that with getFragmentManager() and it resolved the issue.

    UPDATE: I've now been working with childFragmentManager and have some feedback.

    When dealing with inner fragments that are hosted by a fragment (so a fragment within a fragment) use the childFragmentManager. This fragment manager differs from the activities getSupportFragmentManager. The two are not the same. It's a separation of concerns.

    So I've made a rule that fragments hosting child fragments will always use the childFragmentManager and things not inside host fragments can use getSupportfragmentManager.

提交回复
热议问题