Why is this returning the "fragment already added" error and crashing the app?
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
android.support.v4.app.FragmentTransaction ft = fm.beginTransaction();
ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right);
ft.replace(R.id.fragment_container, tempmainfrag);
ft.commit();
for(int i = 0; i < fm.getBackStackEntryCount(); i++)
{
fm.popBackStack();
}
I'm guessing it is because of the for loop as it works without it, but I am needing to clear the back stack, how can I properly do this?