4

There are a several questions addressing that error but none of them have had a fix that worked for this situation.

Whats happening is that we are popping a fragment (which is nested inside a featureFragment) and making a call back to the activity to remove the feature fragment and un-hide a different fragment containing a googleMap.

DetailFragment:

if (mConversationId != null) {
    try {
        return getLayerClient().getConversation(mConversationId);
    } catch (LayerException exc) {
        getFragmentManager().popBackStack();
        ((MainActivity) getActivity()).LayerConnectionLost();

        return null;
    }

Main Activity:

FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
// Only hide the map fragment in order to keep the Google Map in memory as long as possible to avoid being charged
if (fragment != mMapFragment && !mMapFragment.isHidden()) {
    transaction.hide(mMapFragment);
}
// Detach the other fragment views
if (fragment != mToolsFragment && !mToolsFragment.isDetached()) {
    transaction.detach(mToolsFragment);
}
if (mMessageFragment != null ) {
    if (fragment != mMessageFragment && !mMessageFragment.isDetached()) {
        transaction.detach(mMessageFragment);
    }
}
mVisibleFragment = fragment;
if (fragment == mMapFragment) { // map fragment is hidden, so show
    transaction.show(fragment).setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out).commit();
} else { // other fragments are detached, so attach
    transaction.attach(fragment).setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out).commit();
}

getSupportFragmentManager().executePendingTransactions();

The Stack Trace is giving the error on the last line

getSupportFragmentManager().executePendingTransactions();

But in testing I found that it is actually this line of code which is precipitating the error.

transaction.show(fragment).setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out).commit();

Any ideas what I'm dong wrong?

clemens
  • 16,716
  • 11
  • 50
  • 65
Dan Anderson
  • 1,062
  • 13
  • 26

0 Answers0