有没有一种方法,以pre-缓存使用Android的WebView浏览网页? [英] Is there a way to pre-cache a web page for viewing with an Android WebView?

查看:185
本文介绍了有没有一种方法,以pre-缓存使用Android的WebView浏览网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过关于HTML5缓存清单,我已经使用了缓存清单见证了Android确实支持缓存网站。我想用缓存清单,下载所有需要的资源,为我的网站,以preLOAD它,然后打开一个网页视图,并使用pre-缓存资源显示远程网站。我想pferably pre-缓存我的远程网页不知何故,$ P $不使用的WebView的缓存过程。

I've read about the HTML5 cache manifest, and I've seen Android does support caching websites using the cache manifest. I want to use the cache manifest to download all the required resources for my website to preload it, and then open a WebView and display the remote website using the pre-cached resources. I want to pre-cache my remote page somehow, preferably without using a WebView for the caching process.

用一个web视图为$ P $对缓存过程的问题​​在于,装载使用web视图网页呈现,而是执行的只是下载它的页面。

The problem with using a WebView for the pre-caching process is that loading the webpage using a WebView renders and executes the page instead of just downloading it.

我读过这样的:的http://亚历克斯。 tapmania.org/2010/11/html5-cache-android-webview.html ,但有一个支持web视图缓存不是我想要的。我想加载过程是瞬间(假设缓存清单/远程网站的ETag是一样的缓存版本),我完成之后pre-缓存的资源,而不是等待的WebView加载起来,缓存一切的第一次访问。

I've read this: http://alex.tapmania.org/2010/11/html5-cache-android-webview.html, but having a WebView support caching is not what I want. I want the loading process to be instantaneous (assuming the cache manifest / etags of the remote website are the same as the cached version) right after I finish pre-caching the resources, instead of waiting for the WebView to load up and cache everything on the first access.

什么是pre-缓存的网页的正确方式供以后观看?

What is the correct way of pre-caching web pages for viewing later?

谢谢!

推荐答案

你想要做什么,需要实施应用程序缓存,链接资源,饼干和本地数据库存储的使用数据库API的HTML5应用程序的机制,这是一个什么样的浏览器在这几天做的重要组成部分。我不建议自己做缓存,不仅因为它是这么多的工作,也因为我不记得任何方法的WebView 和它的朋友( WebViewClient 等),接受外部缓存。

What you want to do requires implementing a mechanism for app cache, linked resources, cookies, and local database store for HTML5 apps that use database API, and that's an important part of what browsers do in these days. I don't recommend doing the caching by yourself, not only because it's so much work, but also because I can't recall any method in WebView and it's friends (WebViewClient, etc.) that accepts an outside cache.

但你的问题有一个非常简单的解决方案:你可以把一个的WebView 在你看来并设置其能见度消失。然后使其可见,当它已经完成加载页面。 的WebView 也会自动保存在缓存中的应用程序,以便在下次运行时更迅速地加载网页。

But your problem has a very simpler solution: you can put a WebView in your view and set its visibility to gone. Then make it visible when it has finished loading the page. WebView also automatically keeps the cache for your app so that the next time it runs it loads the page more quickly.

有关隐藏你的的WebView ,然后自动显示它你就必须重写 onPageFinished 中的 WebViewClient

For hiding your WebView and then automatically showing it you just have to override onPageFinished in WebViewClient.

这篇关于有没有一种方法,以pre-缓存使用Android的WebView浏览网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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