Android error: Fragment is not currently in the FragmentManager


Sample error:

2021-03-05 00:12:59.453 13821-13821/com.cb.callrecorder E/FragmentManager: Fragment ReceivedCallFragment{23269ee} is not currently in the FragmentManager

Solution:

Change:

getSupportFragmentManager().putFragment(outState, RECEIVED_CALLS_FRAGMENT_KEY, mReceivedCallsFragment);

To :

if (mReceivedCallsFragment.isAdded())
        getSupportFragmentManager().putFragment(outState, RECEIVED_CALLS_FRAGMENT_KEY, mReceivedCallsFragment);

Leave a Reply