没有互联网时在webview中显示页面

时间:2016-08-13 21:00:11

标签: android

我需要从webview保存页面,然后在webview中打开它。我找到了方法saveWebArchive并编写了代码:

        Timestamp tm = new Timestamp(new Date().getTime());
        String fileName = String.format("web_file_%d.mht",tm.getTime());

        String path = dir.toString() + File.separator + fileName;
        view.getWebView().saveWebArchive(path);

然后我加载页面,其中model.getContentPath()是来自上面代码的路径

webView.loadUrl("file:///"+model.getContentPath());

我没有CSS样式等页面... 你能说一下如何从网页上保存和加载看起来像原版的页面吗?

0 个答案:

没有答案