得到webArchive通过web视图saveWebArchive [英] get the webArchive that by webview 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屋!