有几个问题可以解决这个错误,但是没有一个问题能解决这个问题。
发生的事情是我们正在弹出一个片段(嵌套在featureFragment中)并回调活动以删除要素片段并取消隐藏包含googleMap的不同片段。
DetailFragment:
exit
主要活动:
if (mConversationId != null) {
try {
return getLayerClient().getConversation(mConversationId);
} catch (LayerException exc) {
getFragmentManager().popBackStack();
((MainActivity) getActivity()).LayerConnectionLost();
return null;
}
Stack Trace在最后一行给出错误
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();
但是在测试中我发现实际上是这行代码导致了错误。
getSupportFragmentManager().executePendingTransactions();
任何想法我错了什么?