在Android System WebvIEw的最后一次更新(2018年5月30日)之后,代理设置停止了为我工作,代理不再适用于webvIEw.在其他具有代理的浏览器中,它具有相同的效果,代理不设置,阻止的网站无法打开,ip不会更改.返回的错误是主机无解析器或连接失败.
我的设备是Nexus 5X,AndroID 8.1.0.其他人是否面临同样的问题?
我用它来设置代理:
private static boolean setProxyKKPlus(WebVIEw webVIEw, String host, int port, String applicationClassname) { Log.d(LOG_TAG, "Setting proxy with >= 4.4 API."); Context appContext = webVIEw.getContext().getApplicationContext(); System.setProperty("http.proxyHost", host); System.setProperty("http.proxyPort", port + ""); System.setProperty("https.proxyHost", host); System.setProperty("https.proxyPort", port + ""); try { Class applictionCls = Class.forname(applicationClassname); FIEld loadedApkFIEld = applictionCls.getFIEld("mloadedApk"); loadedApkFIEld.setAccessible(true); Object loadedApk = loadedApkFIEld.get(appContext); Class loadedApkCls = Class.forname("androID.app.LoadedApk"); FIEld receiversFIEld = loadedApkCls.getDeclaredFIEld("mReceivers"); receiversFIEld.setAccessible(true); ArrayMap receivers = (ArrayMap) receiversFIEld.get(loadedApk); for (Object receiverMap : receivers.values()) { for (Object rec : ((ArrayMap) receiverMap).keySet()) { Class clazz = rec.getClass(); if (clazz.getname().contains("Proxychangelistener")) { Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class); Intent intent = new Intent("androID.intent.action.PROXY_CHANGE"); onReceiveMethod.invoke(rec, appContext, intent); } } } Log.d(LOG_TAG, "Setting proxy with >= 4.4 API successful!"); return true; } catch (Exception e) { StringWriter sw = new StringWriter(); e.printstacktrace(new PrintWriter(sw)); String exceptionAsstring = sw.toString(); Log.v(LOG_TAG, e.getMessage()); Log.v(LOG_TAG, exceptionAsstring); } return false; }
解决方法:
此代码适用于我的环境(Chrome 67 AndroID 7.0)
for (Object receiverMap : receivers.values()) { for (Object rec : ((ArrayMap) receiverMap).keySet()) { Class clazz = rec.getClass(); boolean targetReceiverFound = false; if (clazz.getname().contains("Proxychangelistener")) { targetReceiverFound = true; } else { final FIEld[] obfuscatedFIElds = clazz.getDeclaredFIElds(); for (FIEld f : obfuscatedFIElds) { if (f.getType().getname().contains("Proxychangelistener")) { targetReceiverFound = true; break; } } } if (targetReceiverFound) { // invoke onReceive() here } }}
总结 以上是内存溢出为你收集整理的上次更新Android System Webview后,代理设置停止工作全部内容,希望文章能够帮你解决上次更新Android System Webview后,代理设置停止工作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)