gpt4 book ai didi

android - 在更新数据和显示 dialogFragment 期间点击主页时崩溃。非法状态异常

转载 作者:行者123 更新时间:2023-12-03 16:46:57 24 4
gpt4 key购买 nike

就我而言,在我的应用程序设置中,我点击更新数据库的按钮,它会显示带有进度的对话框 fragment ,如果我点击主页按钮 - 我的应用程序崩溃。

记录错误:

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1489)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1507)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:634)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:613)
at android.support.v4.app.DialogFragment.dismissInternal(DialogFragment.java:201)
at android.support.v4.app.DialogFragment.dismiss(DialogFragment.java:167)
at com.guardian.glass.ui.settings.SettingsActivity$6.onComplete(SettingsActivity.java:328)
at com.guardian.glass.ui.DialogProgressFragment$1.onDataLoaded(DialogProgressFragment.java:63)

在我的类(class) SettingsActivity 方法的代码中弹出错误。
private void fetchDatabaseFromServer() {
UserOperationsTask getCountriesTask = new UpdateCountries(new DialogProgressFragment() {
@Override
public void onComplete(boolean success) {
dismiss(); // here i get error
updateDatabaseSize();
updateFilters();
MeasureUtils.makeDefaultTemplate(SettingsActivity.this, true);
}
});
getCountriesTask.execute(SettingsActivity.this);
showProgress();
updateDataBaseProfile();
}

我的内心阶层
private class UpdateCountries extends UserOperationsTask {
final DialogProgressFragment progressDialog;

UpdateCountries(DialogProgressFragment progressDialog) {
super(UserOperationsTask.TaskMode.MODE_LOAD_COUNTRIES, null);
this.progressDialog = progressDialog;
}

@Override
public void onLoadFinished(Bundle resultData) {
setRegionLabels();
updateFilters();
hideProgress();
String errorMessage = resultData.getString(UserOperationsTask.RESULT_ERROR_STRING);
if (errorMessage != null) {
Log.d(TAG, "getCountriesFromServer error: " + errorMessage);
showMessage(getString(R.string.info_title), getString(R.string.server_request_error));
} else {
progressDialog.start(SettingsActivity.this, DialogProgressFragment.DialogMode.MODE_UPDATE);
progressDialog.setCancelable(false);
progressDialog.show(getSupportFragmentManager(), DialogProgressFragment.class.getSimpleName());
}
}
}

请告诉我如何最好地解决这个问题?

最佳答案

多谢你们!我找到了解决方案 - 就我而言,相反

dismiss();

更好地使用
dismissAllowingStateLoss();

关于android - 在更新数据和显示 dialogFragment 期间点击主页时崩溃。非法状态异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43470695/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com