Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 获取有关系统代理的信息_Android_Proxy - Fatal编程技术网

Android 获取有关系统代理的信息

Android 获取有关系统代理的信息,android,proxy,Android,Proxy,我正在android应用程序上使用HttpClient。某些用户可以在其设备上配置系统代理。我如何获得信息? 从这一点上,我知道你可以做如下事情: DefaultHttpClient httpclient = new DefaultHttpClient(); HttpHost proxy = new HttpHost("someproxy", 8080); httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, pr

我正在android应用程序上使用
HttpClient
。某些用户可以在其设备上配置系统代理。我如何获得信息? 从这一点上,我知道你可以做如下事情:

DefaultHttpClient httpclient = new DefaultHttpClient();

HttpHost proxy = new HttpHost("someproxy", 8080);
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
问题是我不知道在哪里可以找到代理的主机名和端口。

尝试以下方法:

DefaultHttpClient httpclient = new DefaultHttpClient();

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

if (proxyString != null)
{   
    String proxyAddress = proxyString.split(":")[0];
    int proxyPort = Integer.parseInt(proxyString.split(":")[1]);
    HttpHost proxy = new HttpHost(proxyAddress, proxyPort);

    httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
我没有通过考试。找到了