用于保存显示数据的 WebView.savePicture() 的替代方法
我试图让 WebView
在设备方向发生变化时停止重新加载页面。根据这个答案,我正在查看WebView.saveState()
。该方法的文档说:
请注意,此方法不再恢复此 WebView 的显示数据。请参阅
savePicture(Bundle, File)
和restorePicture(Bundle, File)
以保存和恢复显示数据。
但是当我查看 savePicture()
,我发现它已被弃用:
此方法已弃用。
此方法现已过时。
那么,开发者应该使用什么方法来保存和恢复显示数据呢?
I am trying to get a WebView
to stop reloading the page when the device's orientation changes. Per this answer, I was looking at WebView.saveState()
. The documentation for this method says:
Please note that this method no longer restores the display data for this WebView. See
savePicture(Bundle, File)
andrestorePicture(Bundle, File)
for saving and restoring the display data.
But when I looked at savePicture()
, I found that it's been deprecated:
This method is deprecated.
This method is now obsolete.
In that case, what methods should developers be using to save and restore the display data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的
AndroidManifest.xml
文件中,将此配置行添加到您的 Activity 中:In your
AndroidManifest.xml
file, add this config line to your activity:我遇到了一个非常相似的问题,但必须进行一些添加才能使其适用于各种版本(包括 ICS)。
在主应用程序活动中,我添加了与 Jason 提供的版本略有不同的版本。
我在 Honeycomb 之前就已经这样做了:
我必须制作第一个示例才能使其在所有版本上运行。我目前正在使用片段和 ActionBarSherlock 来实现向后兼容性。
希望这有帮助。
I had a very similar problem but had to make a couple of additions to get it to work with various version (including ICS).
In the main app activity I added a slightly different version of what Jason offered.
I had this working on pre-Honeycomb with:
I had to make the first example to get it running on all versions. I'm currently using fragments and ActionBarSherlock for backwards compatibility.
Hope this helps.