Android的HttpClient的不使用系统代理设置 [英] Android HttpClient Doesn't Use System Proxy Settings
问题描述
当我创建一个<一个href="http://developer.android.com/reference/org/apache/http/impl/client/DefaultHttpClient.html">DefaultHttpClient对象,并尝试打一个网页,该请求不通过我在设置中指定的代理路由。
When I create a DefaultHttpClient object and try to hit a webpage, the request isn't routed through the proxy I specified in Settings.
综观API文档,我没有看到任何地方,我可以指定代理,虽然Android的确实有一个<一个href="http://developer.android.com/reference/org/apache/http/impl/client/DefaultHttpClient.html">Proxy类,允许我读系统的代理设置。
Looking through the API docs, I don't see anywhere where I can specify a proxy though Android does have a Proxy class that allows me to read the system's proxy settings.
有没有一种方法可以让我在使用的代理服务器设置的HttpClient的?
Is there a way I can use the proxy settings in an HttpClient?
推荐答案
尝试:
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpHost proxy = new HttpHost("someproxy", 8080);
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
(从扑杀这里)
这篇关于Android的HttpClient的不使用系统代理设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!