I have a fragments, for example A -> B -> C. When I'm in the fragment C, and press the back button I need to get on a fragment A. That is, fragment B is not necessary to add to backStack. Here is the code which implements the transition between fragments.
FragmentManager fragmentManager = this.getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
Fragment fragment = fragmentManager.findFragmentByTag(tag);
fragment.getArguments().putAll(args);
transaction.replace(idContainer, fragment, tag);
transaction.addToBackStack(null);
transaction.commit();
At the opening of the fragment C, I don't use transaction.addToBackStack(null);
And now I have the following problem. From the fragment С I click the back button and enters the fragment A, but two layers of fragments are superimposed on each other.