Java – Android: The difference between ft.remove() and popBackStack().

Android: The difference between ft.remove() and popBackStack()…. here is a solution to the problem.

Android: The difference between ft.remove() and popBackStack().

I’m trying to remove a fragment from my stack. I’m using this code:

FragmentManager fm = getSupportFragmentManager();
    if (fm != null) {
        FragmentTransaction ft = fm.beginTransaction();
        Fragment currentFragment = fm.findFragmentById(R.id.my_id);
        if (currentFragment != null) {
            ft.remove(currentFragment);
            ft.commit();
        }
    }

Does the above code need to call popBackStack()?

fm.popBackStack();

Related Problems and Solutions