在RxJava订阅中的onSaveInstanceState之后无法执行此操作

时间:2017-12-19 17:51:28

标签: android rx-java rx-android

我有以下代码:

 private void doLogin(String username, String password) {
    authManager.userLogout();
    subscribe(authManager.login(username, password)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .doOnSubscribe(() -> showProgress(R.string.authenticating_label, true))
            .subscribe(userObject -> {
                showProgress(false);
                if (userObject != null ) {
                    loginSuccess(userObject.loginName, userObject.password, userObject.authToken);
                } else {
                    loginFailed(username, password, null);
                }
            }, throwable -> {
                Timber.d(throwable, "Error while Login!");
                showProgress(false);
                loginFailed(username, password, null);
            })
    );

}

loginFailed方法执行简单的DialogFragment show:

android.support.v4.app.DialogFragment.show

不幸的是,我可以看到在某些Android 8.0和8.1设备上引发了异常:

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1842)



29Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
30at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1842)
31at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1860)
32at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:650)
33at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:609)
34at android.support.v4.app.DialogFragment.dismissInternal(DialogFragment.java:205)
35at android.support.v4.app.DialogFragment.dismiss(DialogFragment.java:171)
36at com.cubesoft.zenfolio.browser.activity.BaseActivity.showProgressInternal(BaseActivity.java:205)
37at com.cubesoft.zenfolio.browser.activity.BaseActivity.showProgress(BaseActivity.java:199)
38at com.cubesoft.zenfolio.browser.activity.BaseActivity.showProgress(BaseActivity.java:194)
39at com.cubesoft.zenfolio.browser.activity.LoginActivity.lambda$doLogin$7(LoginActivity.java:200)
40at com.cubesoft.zenfolio.browser.activity.LoginActivity.access$lambda$7(Unknown Source:0)
41at com.cubesoft.zenfolio.browser.activity.LoginActivity$$Lambda$8.call(Unknown Source:8)




从我所看到的,Activity的状态不是丢失(我们不处于pause / resume / onActivityResult状态)。 可能是什么原因?

0 个答案:

没有答案