请在Android中建议关于此例外,如何解决此问题

时间:2014-02-04 08:52:58

标签: android

我有一个看起来像这样的日志,原因是什么以及如何解决这个问题请建议

 java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
           at android.support.v4.app.FragmentManagerImpl.checkStateLoss(SourceFile:1343)
           at android.support.v4.app.FragmentManagerImpl.enqueueAction(SourceFile:1354)
           at android.support.v4.app.BackStackRecord.commitInternal(SourceFile:595)
           at android.support.v4.app.BackStackRecord.commit(SourceFile:574)
           at android.support.v4.app.DialogFragment.dismissInternal(SourceFile:189)
           at android.support.v4.app.DialogFragment.dismiss(SourceFile:155)
           at com.replicon.cloudclock.timeoff.view.TimeOffActivity$5.run(SourceFile:1264)
           at java.util.Timer$TimerImpl.run(Timer.java:284)

这里显示的是我遇到问题的代码片段

final Timer dismissTimeOut = new Timer();
        dismissTimeOut.schedule(new TimerTask() {
            @Override
            public void run() {
                timeOffDialogFragment.dismiss(); 
                dismissTimeOut.cancel(); 

            }
        }, 2000);

1 个答案:

答案 0 :(得分:1)

尝试commitAllowingStateLoss()而不是commit() 文档here

Source