0
我正在使用SupportMapFragment,並在提交時崩潰且出現非法狀態異常。 這裏的代碼如下:setMap上的onSaveInstanceState後無法執行此操作
mSupportMapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.branch_mp_view);
if (mSupportMapFragment == null) {
FragmentManager fragmentManager = getChildFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
mSupportMapFragment = SupportMapFragment.newInstance();
fragmentTransaction.replace(R.id.branch_mp_view, mSupportMapFragment).commit();
}
if (mSupportMapFragment != null) {
mSupportMapFragment.getMapAsync(this);
}
日誌:
Fatal Exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1538)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1556)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:696)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:662)
at com.android.myapp.ui.branch_master.MyFragment.setMap(MyFragment.java:1346)
at com.android.myapp.ui.branch_master.MyFragment.handleSuccessBranchDetail(MyFragment.java:3267)
at com.android.myapp.ui.branch_master.MyFragment$1.onResponse$230aa0b4(MyFragment.java:200)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:68)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
請幫助,我無法重現它,但我現在在crashlytics看到這個崩潰在一段時間出現一次。
[java.lang.IllegalStateException:onSaveInstanceState後無法執行此操作]的可能重複(https://stackoverflow.com/questions/14177781/java-lang-illegalstateexception-can-not-perform-this-action-後onsaveinstanc) – azizbekian