Skip to content Skip to sidebar Skip to footer

Getting Information About The System Proxy

I'm using HttpClient on my android application. Some user can have a system proxy configured on his device. How do I get the information? From this answer I know you can do somethi

Solution 1:

Try this:

DefaultHttpClienthttpclient=newDefaultHttpClient();

StringproxyString= Settings.Secure.getString(getApplicationContext().getContentResolver(), Settings.Secure.HTTP_PROXY);

if (proxyString != null)
{   
    StringproxyAddress= proxyString.split(":")[0];
    intproxyPort= Integer.parseInt(proxyString.split(":")[1]);
    HttpHostproxy=newHttpHost(proxyAddress, proxyPort);

    httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}

I did not test through. Found here.

Post a Comment for "Getting Information About The System Proxy"