Disable proxies programmatically

I enabled proxies in my application through the ProxySettings class, but now I want to disable it so that the proxy ON / OFF button works.

I searched and tried a lot, but could not find a way to stop the proxy server and continue using normal Wi-Fi ...

I tried the following code from the ProxySettings class, which I got from Stack Overflow:

public static void resetProxy(Context ctx) throws Exception { Object requestQueueObject = getRequestQueue(ctx); if(requestQueueObject != null) { setDeclaredField(requestQueueObject, "mProxyHost", null); } } 

How can I fix this problem?

+6
source share

Source: https://habr.com/ru/post/951955/


All Articles