在Android设备(包括4.4.2)上,默认的浏览器和Chrome支持HTML5缓存清单.但是,在这些相同的设备上,WebView组件似乎不支持HTML5缓存清单.有谁知道如何让WebView组件支持HTML5清单?
试试这个代码:
private void enableHTML5AppCache() {
webView.getSettings().setDomStorageEnabled(true);
// Set cache size to 8 mb by default. should be more than enough
webView.getSettings().setAppCacheMaxSize(1024*1024*8);
// This next one is crazy. It's the DEFAULT location for your app's cache
// But it didn't work for me without this line
webView.getSettings().setAppCachePath("/data/data/"+ getPackageName() +"/cache");
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
}
Run Code Online (Sandbox Code Playgroud)
这里是链接。
归档时间: |
|
查看次数: |
7606 次 |
最近记录: |