Android HttpClient 不使用系统代理设置 [英] Android HttpClient Doesn't Use System Proxy Settings
本文介绍了Android HttpClient 不使用系统代理设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我创建一个 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 确实有 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屋!
查看全文