Created
July 23, 2014 05:11
-
-
Save Reacoder/8ad855b7715f6c4b19e2 to your computer and use it in GitHub Desktop.
Add this in father fragment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This seems to be a bug in the newly added support for nested fragments. | |
* Basically, the child FragmentManager ends up with a broken internal state | |
* when it is detached from the activity. A short-term workaround that fixed | |
* it for me is to add the following to onDetach() of every Fragment which | |
* you call getChildFragmentManager() on: | |
*/ | |
@Override | |
public void onDetach() { | |
super.onDetach(); | |
try { | |
Field childFragmentManager = Fragment.class | |
.getDeclaredField("mChildFragmentManager"); | |
childFragmentManager.setAccessible(true); | |
childFragmentManager.set(this, null); | |
} catch (NoSuchFieldException e) { | |
e.printStackTrace(); | |
Logger.d("----- MainPopularFragment onDetach NoSuchFieldException ----"); | |
} catch (IllegalAccessException e) { | |
e.printStackTrace(); | |
Logger.d("----- MainPopularFragment onDetach IllegalAccessException ----"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment