当我尝试创建另一个对话框时,我的应用程序崩溃了

时间:2018-06-17 11:10:24

标签: android crash dialog

我已经可以与我的应用分享内容了。当发生这种情况时,会弹出一个altertdialog并询问如何处理它。对于其中一个选择,之后会弹出另一个对话框。但问题出在这里:当我做show();时,我的应用程序崩溃了:

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
        at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:2053)
        at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:2079)
        at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:678)
        at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:632)
        at android.support.v4.app.DialogFragment.show(DialogFragment.java:143)

以下是我如何制作对话框:

.subscribe((@NonNull InfoItem result) -> {
    DDialog dDialog = new DDialog();
    dDialog.doSomethingWith(result)
    dDialog.show(getSupportFragmentManager(), "dDialog");
    finish();
    return;
}, (@NonNull Throwable throwable) -> {
    onError();
});

1 个答案:

答案 0 :(得分:0)

private val timeOut: Long = 30 * 1000 .connectTimeout(timeOut, TimeUnit.MILLISECONDS) .readTimeout(timeOut, TimeUnit.MILLISECONDS) .writeTimeout(timeOut, TimeUnit.MILLISECONDS) 是异步的,这意味着在调用dDialog.show(getSupportFragmentManager(), "dDialog");之后,您调用show(),在您的对话框有机会出现之前完成当前活动,并在尝试时为了显示,活动已经处于不正确的状态