HTML5缓存的问题与Android的WebView [英] Html5 cache problems with android webview

查看:721
本文介绍了HTML5缓存的问题与Android的WebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我试着与我的Andr​​oid设备缓存我的Web应用程序。我什么都试过,但没有将工作。缓存将不仅在Android设备上,而不是在其他设备上刷新!下面你看到所有的设置我已经设置缓存的Web应用程序。

Hello I tried to cache my web application with my android device. I tried everything but nothing will work. The Cache will not refresh only on android devices and not on other devices! Below you see all the settings I've set to cache the web application.

@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/");

}

在这里我把我的缓存:

here I set my cache:

<html manifest="cache.manifest">

我希望有人能帮助我。谢谢

I hope someone can help me. Thanks

推荐答案

web.getSettings()。setAppCachePath()设置的本地目录中存储缓存文件不是从哪里装载清单。

web.getSettings().setAppCachePath() set's the local directory where to store the cached files not where to load the manifest from.

清单已在HTML文件中引用要缓存:

The manifest has to be referenced in the HTML file you want to cache:

    <html manifest="cache.manifest">


你是什么意思有:缓存不仅会在Android设备上,而不是在其他设备上刷新!
缓存的文件只有在清单的内容已经改变将被更新。

http://appcachefacts.info/

http://jonathanstark.com/blog/2009/09/27/debugging-html-5-offline-application-cache/

http://dev.opera.com/articles/view/offline-应用-HTML5的应用程序缓存/

这篇关于HTML5缓存的问题与Android的WebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆