android webview获取源代码,且不能显示全的日志

xiaoxiao2021-02-27  428

1、在要打印日志的地方或者工具类中添加如下代码 if(msg.length() > 4000) {//打印日志长度超过4000字符的完整日志 for(int i=0;i<msg.length();i+=4000){ if(i+4000<msg.length()) Log.i("eeee",msg.substring(i, i+4000)); else Log.i("eeee",msg.substring(i, msg.length())); } } else{ Log.e("eeee",msg); }注意要用log.i,而不要用log.e,否则仍然是显示不全的 2、获得url中的源代码 webview.addJavascriptInterface(js, "html_show_fingure"); public void onPageFinished(WebView webView, String s) { super.onPageFinished(webView, s); webView.loadUrl("javascript:window.html_show_fingure.getSource('<head>'+" + "document.getElementsByTagName('html')[0].innerHTML+'</head>');"); } @JavascriptInterface public void getSource(String html) { L.e(html); }
转载请注明原文地址: https://www.6miu.com/read-6208.html

最新回复(0)