Adding fragments without saving to history stack?
android, android-fragments
Solution
When you use FragmentTransaction to add fragment there is addToBackStack() method, if you don't use it, it won't be in the stack.
// it won't add to stack
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
// fragment will be added to stack
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.addToBackStack("placeholder")
commit();
Problem
Is there any way replace a fragment with `FragmentTransaction's replace`, and NOT add it to history stack? I just want my app to dont remember it, when i push back button.