Last active
September 5, 2015 12:10
-
-
Save danielwilson1702/4e4e4aee1c80dea5d817 to your computer and use it in GitHub Desktop.
Activity hosting fragments with back button listeners
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() { | |
tellFragments(); | |
super.onBackPressed(); | |
} | |
private void tellFragments(){ | |
List<Fragment> fragments = getSupportFragmentManager().getFragments(); | |
for(Fragment f : fragments){ | |
if(f != null && f instanceof BaseFragment) | |
((BaseFragment)f).onBackPressed(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment