My scenario : Activity 1 consists of Fragments A-> B-> C. All the fragments are added using this code :
FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.content, fragment, TAG); ft.addToBackStack(TAG); ft.commit();
Now, from fragment C, I want to directly return to Fragment A. Therefore, I've commented
ft.addToBackStack(TAG) while adding Fragment C. So when I press back button from C I directly get Fragment A on the screen.
However, Fragment C is not replaced by A. In fact, both the fragments are visible. How do I solve this issue?