I have two fragments that I change back and forth depending on the current users state. I use the following on the code below and it works great when using the app pretty much all the time. The only time i get a force close though is when i log the user out, log back in, user changes their state, and then I get a "java.lang.IllegalStateException: Activity has been destroyed". The error points to the last line in the code but I'm still confused why it happens only in that one time.
FrameLayout fLayout = (FrameLayout) rootView.findViewById(R.id.frameLayoutNC);
fLayout.removeAllViews();
android.support.v4.app.FragmentManager fragmentManager = getChildFragmentManager();
android.support.v4.app.FragmentTransaction ft = fragmentManager.beginTransaction();
CCF newFragment = new CCF();
ft.replace(R.id.frameLayoutNotCharging, newFragment);
ft.setTransition(android.support.v4.app.FragmentTransaction.TRANSIT_NONE);
ft.addToBackStack(null);
ft.commitAllowingStateLoss();