安卓的WebView从API级别11开始就有这样的saveWebArchive方法:
它可以将整个网站保存为网络存档,这很棒!但是我怎样才能把下载的内容放回get视图呢?我试过了
webview.loadUrl(Uri.fromFile(mywebarchivefile));,但它只在屏幕上显示xml。
我尝试使用WebArchiveReader,他们告诉我可以显示webArchive,但它只是解析xml,我得到了相同的结果。
我现在该怎么做?
发布于 2013-12-15 00:29:30
您可以通过以下方法将保存的归档文件加载到webView中:首先使用reading the archive into a String,然后调用:
webView.loadDataWithBaseURL(null, archiveString, "application/x-webarchive-xml", "UTF-8", null);发布于 2019-07-02 19:38:45
简单版本:
包含文件:// loadUrl的方案
mWebView.loadUrl("file://"+getContext().getFilesDir().getPath()+"/example.mhtml");
//file:///data/user/0/{your app package name}/files/example.mhtml“自己处理内容”版本:
mWebView.loadDataWithBaseURL(/*source url, or even https://example.com/, don't put null or empty string*/, dataString, "multipart/related", "utf-8","");后面添加\r\n
https://stackoverflow.com/questions/18504404
复制相似问题