SimpleDialogFragment从Service抛出错误

时间:2014-04-28 14:36:52

标签: android android-dialogfragment illegalstateexception

我有一个网络更改侦听器正在侦听android.net.conn.CONNECTIVITY_CHANGE。该侦听器调用方法并在出现错误时显示一个对话框。这在大多数情况下有效,但是当应用程序在后台并且此对话框尝试显示时出现错误。 这是我的代码

if(sdf != null){
    sdf.dismiss();
}
sdf = (SimpleDialogFragment) SimpleDialogFragment.createBuilder(mActivity, mActivity.getSupportFragmentManager())
    .setTitle(mActivity.getString(R.string.miscNoConnTitle))
    .setMessage(mActivity.getString(R.string.miscNoConnDesc)).show();

我收到的错误是

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1343)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1354)
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:127)
at eu.inmite.android.lib.dialogs.BaseDialogBuilder.show(BaseDialogBuilder.java:85)
at eu.inmite.android.lib.dialogs.SimpleDialogFragment$SimpleDialogBuilder.show(SimpleDialogFrag ment.java:1)

我听说这可能是一个已知问题,所以我该如何解决这个问题?

由于

P.S。如果您没有注意到我正在使用SimpleDialogFragment

的代码

0 个答案:

没有答案