【问题标题】:Is android WebView saveState/restoreState broken in 4.0+android WebView saveState/restoreState 在 4.0+ 中是否损坏
【发布时间】:2012-06-13 16:33:07
【问题描述】:

我已经实现了 webview saveState() restoreState() 逻辑来恢复 webview 的当前页面和历史记录,如下所示:

public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    ...

    if(savedInstanceState != null)
    {
        webView.restoreState(savedInstanceState);
    }
    else
    {
        webView.loadUrl(url);
    }
}

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    if(webView != null) webView.saveState(outState);
}

我正在测试状态保存,方法是在应用处于后台时通过 DDMS 终止应用进程。

重新启动应用程序时,它在 2.x 设备上按预期运行,但在 4.x 设备上不正常。相反,我要么得到一个空白的 webview,要么奇怪的是,显示历史中的第一页。

有没有人在使用 webview 时遇到过 4.x 的特定问题?

【问题讨论】:

    标签: android android-webview


    【解决方案1】:

    解决了这个问题。

    Save/restore 不是问题,原来问题出在我正在加载的特定 URL 上。他们在 3.0+ 中包含了一个与此错误相冲突的井号:Issue Details

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-25
      相关资源
      最近更新 更多