Since your activity is being destroyed, your fragments will automatically be destroyed. Hence, there is no need for you to remove them. Simply delete your onDestroyView()
method.
I know that you're not supposed to have fragments within fragments, but the code worked in the past and there's no way around it anyway.
First, fragments within fragments are supported via the Android Support package's backport of fragments and the native Android 4.2+ implementation of fragments.
Second, you are not doing fragments within fragments, at least not based on the code shown here. For some reason, your TrackFragment
is managing another top-level fragment (your SupportMapFragment
), rather than delegating that work to the activity.