启动v4.DialogFragmet触发RuntimeException:Unable to stop activity

来源:互联网 发布:移动网络玩lol哪个区 编辑:程序博客网 时间:2024/09/21 06:16

经测试,当在onStop方法里显示DialogFragment是,会出现IllegalStateException异常:Can not perform this action after onSaveInstanceState...

但是在onPause方法里启动DialogFragment不会出现问题

通过上面两点可以再当前的onStop和onResume方法里记录变量,来表示当前activity的状态是否适合启动DialogFragment。

注意:

protected void onSaveInstanceState (Bundle outState)

If called, this method will occur before onStop(). There are no guarantees about whether it will occur before or after onPause().
所以,在onPause()和onSaveInstanceState()方法里同时设置变量状态,则不会出现此问题。



0 0
原创粉丝点击