I've got three Simple Fragments: FragmentA, FragmentB, FragmentC.
FragmentA -> FragmentB:
FragmentB fragment2 = new FragmentB ();
FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.addToBackStack(null);
fragmentTransaction.replace(R.id.mainLayout, fragment2);
fragmentTransaction.commit();
FragmentB -> FragmentC:
FragmentC fC= new FragmentC ();
FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.mainLayout, fC);
fragmentTransaction.addToBackStack("FragmentA");
fragmentTransaction.commit();
FragmentC -> FragmentA:
getActivity().getSupportFragmentManager().popBackStack("FragmentA",0);
The Issue is that I always return to FragmentB altough my aim is to return to FragmentA. What am I missing?