如何强制我的应用程序不使用3G数据代理设置我的、应用程序、数据

2023-09-06 02:46:05 作者:好听的火山有哪些 火山小视频好听的昵称

我开发一个Android应用程序和设备pre 4.0(ICS)的应用程序工作正常连接到HTTP和HTTPS后端上的WiFi和3G数据连接。但在我的ICS 4.0.3设备,应用程序只能通过无线网络连接到HTTPS(它连接细到http双方WiFi和3G)。我意识到,通过手动将APN设置和删除代理,我的应用程序可以通过3G连接到HTTPS后端。所以我的问题是我怎么能强迫的HttpClient通过code 为不可以使用代理服务器设置?谢谢

I am developing an android app and on devices pre 4.0 (ics) the app works fine connecting to http and https backends on WiFi and 3G data connections. But on my ICS 4.0.3 device, the app ONLY connects to https via WiFi (it connects fine to http on both wifi and 3g). I realised that by manually going to the APN settings and removing the proxy, my app can connect to the https backend via 3g. So my question is how can i force httpclient to NOT use the proxy settings via code? Thanks

推荐答案

首先,感谢的酷花花公子的回答自己的提问。我有同样的问题,但没有使用的HttpClient而是HttpURLConnection的直接。 在这种情况下,溶液是如下:

First of all, thanks Cool Dude for answering your question yourself. I had the same problem but was not using HttpClient but instead HttpURLConnection directly. In that case the solution is the following:

myUrl.openConnection(java.net.Proxy.NO_PROXY);