android - 如何恢复 webview 状态
问题描述
我正在像这样保存我的状态:
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
binding.webView.restoreState(savedInstanceState)
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
binding.webView.saveState(outState)
}
创建时
shouldRestoreState = savedInstanceState?.let {
true
} ?: false
bundle = savedInstanceState
OnViewCreated
if (shouldRestoreState && bundle != null) {binding.webView.restoreState(bundle)} else { load normally }
它确实有效但
A.几次屏幕旋转后,屏幕变黑几秒钟,然后加载显示页面内容
B.当我在 youtube 页面中旋转屏幕时,它会加载屏幕但没有任何内容。
我的代码做错了什么,我该如何解决?
解决方案
推荐阅读
- reactjs - 错误 R10(启动超时)-> 使用 React 在 HEROKU 上启动后 60 秒内,Web 进程无法绑定到 $PORT
- android -
Android上的Unity3d sqlite找不到数据库 - python - 是否可以在同一执行期间运行 memory_profiler 和 line_profiler?
- angular - 我点击添加类活动和兄弟姐妹我在角度删除类
- ios - 如何与自定义 UITableViewCell 类交互?
- reactjs - 使用离子+反应时的路线守卫
- unicode - 为什么Byte level BPE的vocab size小于Unicode的vocab size?
- android - 音频声音未在 Android 中播放
- android - 必须 onCreateOptionsMenu 成为每个活动的实现吗?
- javascript - Discord.js 在一条消息中发送多个附件