Last active
October 26, 2020 12:15
-
-
Save artem-zinnatullin/6916740 to your computer and use it in GitHub Desktop.
Android support library onActivityResult() bug fix for nested fragments
This file contains 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
@Override | |
public void onActivityResult(int requestCode, int resultCode, Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); | |
// notifying nested fragments (support library bug fix) | |
final FragmentManager childFragmentManager = getChildFragmentManager(); | |
if (childFragmentManager != null) { | |
final List<Fragment> nestedFragments = childFragmentManager.getFragments(); | |
if (nestedFragments == null || nestedFragments.size() == 0) return; | |
for (Fragment childFragment : nestedFragments) { | |
if (childFragment != null && !childFragment.isDetached() && !childFragment.isRemoving()) { | |
childFragment.onActivityResult(requestCode, resultCode, data); | |
} | |
} | |
} | |
} |
How to use with in child fragment onActivityResult
Thank you! You saved a lot of my time!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where to put this code inside fragment or child fragments.....
Please help me.... It's urgent.