We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
private static boolean setProxy(Context ctx, String host, int port) { boolean ret = false; try { if(Build.VERSION.SDK_INT < 14) { Object requestQueueObject = getRequestQueue(ctx); if (requestQueueObject != null) { //Create Proxy config object and set it into request Q HttpHost httpHost = new HttpHost("24.245.17.166", 1767, "http"); setDeclaredField(requestQueueObject, "mProxyHost", httpHost); //Log.d("Webkit Setted Proxy to: " + host + ":" + port); ret = true; } } else { ret=setICSProxy(host,port); } } catch (Exception e) { Log.e("ProxySettings","Exception setting WebKit proxy settings: " + e.toString()); } return ret; } private static boolean setICSProxy(String host, int port) throws ClassNotFoundException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { Class webViewCoreClass = Class.forName("android.webkit.WebViewCore"); Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties"); if (webViewCoreClass != null && proxyPropertiesClass != null) { Method m = webViewCoreClass.getDeclaredMethod("sendStaticMessage", Integer.TYPE, Object.class); Constructor c = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE, String.class); m.setAccessible(true); c.setAccessible(true); Object properties = c.newInstance(host, port, null); m.invoke(null, PROXY_CHANGED, properties); return true; }
Original issue reported on code.google.com by [email protected] on 17 May 2012 at 7:34
[email protected]
The text was updated successfully, but these errors were encountered:
Well, this is just modified code I'm using but I'm sure you see how to adapt it to the current codebase.
Original comment by [email protected] on 17 May 2012 at 7:36
Sorry, something went wrong.
private static boolean setProxy(Context ctx, String host, int port) { boolean ret = false; try { if(Build.VERSION.SDK_INT < 14) { Object requestQueueObject = getRequestQueue(ctx); if (requestQueueObject != null) { //Create Proxy config object and set it into request Q HttpHost httpHost = new HttpHost(host, port, "http"); setDeclaredField(requestQueueObject, "mProxyHost", httpHost); //Log.d("Webkit Setted Proxy to: " + host + ":" + port); ret = true; } } else { ret=setICSProxy(host,port); } } catch (Exception e) { Log.e("ProxySettings","Exception setting WebKit proxy settings: " + e.toString()); } return ret; } private static boolean setICSProxy(String host, int port) throws ClassNotFoundException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { Class webViewCoreClass = Class.forName("android.webkit.WebViewCore"); Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties"); if (webViewCoreClass != null && proxyPropertiesClass != null) { Method m = webViewCoreClass.getDeclaredMethod("sendStaticMessage", Integer.TYPE, Object.class); Constructor c = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE, String.class); m.setAccessible(true); c.setAccessible(true); Object properties = c.newInstance(host, port, null); m.invoke(null, PROXY_CHANGED, properties); return true; }
No branches or pull requests
Original issue reported on code.google.com by
[email protected]
on 17 May 2012 at 7:34The text was updated successfully, but these errors were encountered: