Last active
February 20, 2017 17:32
-
-
Save PepDevils/f96e1bf1d77e7566c6d2cb372d1499d9 to your computer and use it in GitHub Desktop.
Close all Fragments before the activity in onBackPressed button..
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
@Override | |
public void onBackPressed() { | |
List<Fragment> all_frags = getSupportFragmentManager().getFragments(); | |
if(all_frags != null){ | |
if (all_frags.size() == 0) { | |
super.onBackPressed(); | |
} else { | |
for (Fragment frag : all_frags) { | |
getSupportFragmentManager().beginTransaction().remove(frag).commit(); | |
} | |
} | |
}else{ | |
super.onBackPressed(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment