美文网首页
WebView开发问题集锦

WebView开发问题集锦

作者: 墨留痕 | 来源:发表于2018-06-05 14:22 被阅读0次

1、网页二次进入,JS 方法未成功加载 或者 不执行

//webview 销毁时调用了以下方法,注释即可
webView.pauseTimers();

2、网页退出时销毁

        if (webView != null) {
            try {
                if (webView.getParent() != null) {
                    ((ViewGroup) webView.getParent()).removeView(webView);
                }
                webView.clearHistory();
                webView.clearCache(true);
                webView.loadUrl("about:blank");
                //webView.loadDataWithBaseURL(null, "", "text/html", "utf-8", null);
                webView.freeMemory();
                webView.destroy();
                //                }
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
            webView = null; // Note that mWebView.destroy() and mWebView = null do the exact same thing
        }

相关文章

网友评论

      本文标题:WebView开发问题集锦

      本文链接:https://www.haomeiwen.com/subject/lqwpsftx.html