Created
April 21, 2016 15:26
-
-
Save paxti/e289a1a041530bd8620ec1a9b0dc3650 to your computer and use it in GitHub Desktop.
Nested fragments backstack handling
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 onBackPressed() { | |
FragmentManager fm = getSupportFragmentManager(); | |
for (Fragment frag : fm.getFragments()) { | |
if (frag.isVisible()) { | |
FragmentManager childFm = frag.getChildFragmentManager(); | |
if (childFm.getBackStackEntryCount() > 0) { | |
childFm.popBackStack(); | |
return; | |
} | |
} | |
} | |
super.onBackPressed(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment