得到webArchive通过web视图saveWebArchive [英] get the webArchive that by webview saveWebArchive

查看:3023
本文介绍了得到webArchive通过web视图saveWebArchive的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android的WebView中有因为这种方法saveWebArchive API级别11:

Android's WebView has this saveWebArchive method since API level 11:

它可以将整个网站保存为webarchives,这是伟大的!可是我怎么下载的内容返回到网页视图?我试过

It can save entire websites as webarchives, which is great! But how do I get the downloaded contents back into a webview? I tried

webview.loadUrl(Uri.fromFile(mywebarchivefile));
但是,只有在屏幕上显示的XML。

webview.loadUrl(Uri.fromFile(mywebarchivefile)); But that only displays xml on the screen.

我尝试使用WebArchiveReader谁告诉我可以显示webArchive,但它只是解析XML,我也得到了同样的结果。

I try use WebArchiveReader who tell me can display the webArchive, but it just parse xml and i get the same result.

我怎么办?

推荐答案

您可以将保存的档案先的阅读文档解压缩到一个String ,然后调用:

You can load the saved archive into your webView by first reading the archive into a String and then calling:

webView.loadDataWithBaseURL(null, archiveString, "application/x-webarchive-xml", "UTF-8", null);

这篇关于得到webArchive通过web视图saveWebArchive的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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