Skip to content

Changed calls to getTargetFragment() to getParentFragment() to solve crashes on rotation#46

Open
irenenaya wants to merge 3 commits intojjobes:masterfrom
irenenaya:master
Open

Changed calls to getTargetFragment() to getParentFragment() to solve crashes on rotation#46
irenenaya wants to merge 3 commits intojjobes:masterfrom
irenenaya:master

Conversation

@irenenaya
Copy link

The app would crash on rotation or backgrounding. That is due to the target fragment not being found when the hosting fragment is recreated. According to the discussions here: https://issuetracker.google.com/issues/36969568
and in many other places, the issue mainly is caused by the calls to setTargetFragment() and getTargetFragment(). The SlideDateTimeDialogFragment class calls for the ChildFragmentManager (as opposed to a FragmentManager) when instantiating the ViewPagerAdapter. Therefore, the DateFragment and TimeFragment should have the Dialog as parent.
The issue is solved by changing the calls to getTargetFragment() in the callbacks from TimeFragment and DateFragment to be calls to getParentFragment(), and by removing the calls to setTargetFragment() in the getItem() method of the SlideDateTimeDialogFragment class.

@luyuan11233
Copy link

you are right,thank you

@lunay0ung
Copy link

thanks for your help!

@Kwenziwa
Copy link

Thank you soo much this worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants