I am using fragmentTransaction to proceed through fragments, it looks like this:
FragmentManager fm = oldFragment.getFragmentManager();
FragmentTransaction fragmentTransaction = fm.beginTransaction();
fragmentTransaction.add(oldFragment.getId(), newFragment, tag);
fragmentTransaction.hide(oldFragment);
fragmentTransaction.addToBackStack(tag);
fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
fragmentTransaction.commit();
Having several fragments I want to skip some of them when going back.
Example:
Frag1 -> (Press Next) -> Frag2 -> (Press Next) -> Frag3 -> (Press Back) -> Frag1
This solution works when I use replace instead of add and hide
getFragmentManager().popBackStack(
tag,
FragmentManager.POP_BACK_STACK_INCLUSIVE);
Reference` Skip some fragments onBackPressed
But in my case the skipped fragments are shown for a brief moment. How can I make it as if the fragments in between were never there?