加载 URL 时出错。我还提供了所有必需的许可。 控制台 -> 错误:-6 net::ERR_CONNECTION_CLOSED。
webview.setListener(this, this)
webview.setDownloadListener(this)
webview.run {
setMixedContentAllowed(true)
setGeolocationEnabled(true)
setCookiesEnabled(true)
setThirdPartyCookiesEnabled(true)
}
with(webview.settings) {
javaScriptCanOpenWindowsAutomatically = true
domStorageEnabled = true
javaScriptEnabled = true
userAgentString = "Android WebView"
allowFileAccess = true
allowContentAccess = true
allowFileAccessFromFileURLs = true
allowUniversalAccessFromFileURLs = true
}
webview.clearCache(true);
webview.clearHistory();
webview.reload();
//load url
webview.loadUrl(url)
最佳答案
您是否在使用百度之类的杀毒软件?如果您正在使用,那么我喜欢这个适合您的解决方案 please translate this link into english据此
“亲,第一次发帖求助,一般都是百度,这次没有百度,求助~
部分手机Android客户端https-webview提示ERR_CONNECTION_CLOSED,已百度,未解决。
访问https页面不通,但是访问https服务正常 (之前Android 6.0无法访问https服务,后来在tomcat配置中添加了ciphers="SSL_RSA_WITH_RC4_128_SHA"等信息)。
调试时,监听webview-onrecievederr时,返回ERR_CONNECTION_CLOSED给
听听 onrecievedsslerr。好像没有反射(reflect)出来,这里的日志也没有打印出来。 . 代码里面的OnReceivedSslError如下: handler.proceed();//接受所有网站的证书 并打印日志信息,但是运行时,并没有打印日志信息
暂时已知的手机型号如OPPO R9、三星S6、华为mate 8。
开发环境调试时(代码没改),生产环境出现这种情况的手机,但是开发环境打开了相关的https-webview。
将生产环境的tomcat配置文件server.xml放到开发环境运行调试,也正常。
因为百度说可能是端口问题,然后开发环境将tomcat ssl-port配置为8443或者9010调试,也正常。
生产环境做了apache负载均衡(tomcat分别部署在4台主机上),外网https-9010对应内网https-8443。
请大神指点。"
关于android - 通过类 WebView 加载 URL 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54231547/