在应用程序处于后台时显示 DialogFragment

问题描述

案例是在我收到异步任务的响应后,我想显示一个 DialogFragment。 但是,如果用户在应用程序仍在等待响应时将应用程序置于后台,则在响应到来的那一刻和 .show DialogFragment 它将崩溃。

我已通过尝试捕获 .show 立即修复,但在用户返回应用程序后不会显示 DialogFragment。

有没有一种干净的方法让应用程序在后台或下一个 onResume 时继续显示 DialogFragment ?

我在谷歌搜索时发现的唯一方法是使用 ActivityDialog,但这需要付出很多努力。

编辑:嗯,我现在实际上可以用 commitStateLoss ._ 来显示它。 从 customErrorDialog.show(((FragmentActivity) context).getSupportFragmentManager(),"TAG"); 到 ((FragmentActivity)context).getSupportFragmentManager().beginTransaction().add(customErrorDialog,"TAG").commitAllowingStateLoss();

idk 如果这对某些特定情况有危险

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)