在 Activity 的
runOnUiThread()
方法中,我试图显示一个 ProgressDialog。 FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
ProgressDialogFragment mProgressDialogFragment = new ProgressDialogFragment();
mProgressDialogFragment.show(fragmentTransaction, TAG);
这里ProgressDialogFragment
扩展了DialogFragment
。我已经在许多设备上测试过,没有出现任何崩溃。但在华硕手机上,每当我显示对话框时,就会不断出现以下崩溃。 华硕手机的操作系统版本是4.4.2。
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1360)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1378)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:595)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:574)
at android.support.v4.app.DialogFragment.show(DialogFragment.java:155)
at com.trimble.android.trimbleone.activity.ProgressDialogHandlerActivity.showProgressDialog(ProgressDialogHandlerActivity.java:72)
at com.trimble.android.trimbleone.activity.UICallbackHandlerActivity$processThread$7.run(UICallbackHandlerActivity.java:222)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5061)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
at dalvik.system.NativeStart.main(NativeStart.java)