Android HttpClient 不使用系统代理设置
当我创建 DefaultHttpClient 对象并尝试点击网页,请求不会通过我在“设置”中指定的代理进行路由。
浏览 API 文档,我没有看到任何可以指定代理的地方,尽管 Android 确实有 Proxy 类,允许我读取系统的代理设置。
有没有办法可以在 HttpClient 中使用代理设置?
When I create a DefaultHttpClient object and try to hit a webpage, the request isn't routed through the proxy I specified in Settings.
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.
Is there a way I can use the proxy settings in an HttpClient?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试:(
从此处挑选)
Try:
(culled from here)
首先,我将确保请求符合您在 Android 设备设置中设置的代理设置属性。您可以通过查看 android.provider.Settings 中的 System 类来通过代码确定这一点;
要确定用户是否有系统代理设置,您可以执行以下操作:
如果您有 DefaultHTTPClient 的实例,那么您可以检查它是否也有相关的代理设置。
这些都是“获取”代理设置的方法,并且“设置”方法以相同的方式实现,通过 System.setProperty 或 httpclient.setParams。
希望这有帮助!
Firstly, I would make sure that the request is adhering to the proxy settings properties you set in the Android Device's settings. You can determine this via code by looking at the System class in android.provider.Settings;
To identify if the user had system proxy settings, you can do the following:
If you have an instance of DefaultHTTPClient, then you can check whether it has the relevant proxy settings as well.
These are all ways to 'get' the proxy settings, and the 'set' methods are implemented in the same way, either through System.setProperty or httpclient.setParams.
Hope this helped!
我正在开发 Android 代理库,尝试抽象每个 Android 版本对代理设置的访问权限。您可以轻松获取用户当前选择的代理设置。
I'm developing the Android Proxy Library that try to abstract the access to proxy settings for every Android version. You can easily get the proxy settings currently selected by the user.
尝试:
或
或
Try :
or
or