FragmentManager NullPointerException when trying to commitAllowingStateLoss
Context: I have an Activity with a Fragment and 3 InnerFragments . When the Fragment onDestroy() is called, I want to remove the inner fragments from the FragmentManager . The code from onDestroy() is below. Problem: FragmentManager throws NullPointerException , probably when commitAllowingStateLoss() is called. I don't understand why. @Override public void onDestroy() { super.onDestroy(); if (getFragmentManager().findFragmentById(R.id.fragment_framelayout_left) != null) { FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.remove