【问题标题】:Html5 cache problems with android webviewandroid webview的Html5缓存问题
【发布时间】:2012-06-03 17:45:50
【问题描述】:

您好,我尝试使用我的 Android 设备缓存我的 Web 应用程序。我尝试了一切,但没有任何效果。缓存不会只在安卓设备上刷新,在其他设备上不会刷新!您可以在下面看到我为缓存 Web 应用程序所做的所有设置。

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    web = (WebView) findViewById(R.id.webview);
    web.setWebViewClient(new myWebClient());
    web.getSettings().setJavaScriptEnabled(true);

    web.getSettings().setCacheMode(web.getSettings().LOAD_NORMAL);
    web.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    web.getSettings().setUserAgentString(getString(R.string.user_agent_suffix));   


    web.getSettings().setAppCachePath("http://192.168.0.62/lastversion/cache.manifest");
    web.getSettings().setAllowFileAccess(true);
    web.getSettings().setAppCacheEnabled(true);
    web.getSettings().setDomStorageEnabled(true);
    web.loadUrl("http://192.168.0.62/lastversion/");

}

在这里我设置了我的缓存:

<html manifest="cache.manifest">

我希望有人可以帮助我。谢谢

【问题讨论】:

    标签: html webview android-webview html5-appcache android-websettings


    【解决方案1】:

    web.getSettings().setAppCachePath() 设置存储缓存文件的本地目录,而不是加载清单的位置。

    清单必须在您要缓存的 HTML 文件中引用:

        <html manifest="cache.manifest">
    

    你的意思是:“缓存不会只在安卓设备上刷新,在其他设备上不会刷新!” 仅当清单内容发生更改时,才会更新缓存文件。
    http://appcachefacts.info/
    http://jonathanstark.com/blog/2009/09/27/debugging-html-5-offline-application-cache/
    http://dev.opera.com/articles/view/offline-applications-html5-appcache/

    【讨论】:

      猜你喜欢
      • 2011-10-04
      • 1970-01-01
      • 2011-01-04
      • 2011-11-27
      • 2013-01-08
      • 2011-09-22
      • 2011-12-29
      • 2011-10-04
      • 1970-01-01
      相关资源
      最近更新 更多