访问中国移动的Wap网络需要设置代理: Host:"10.0.0.172" Port:80
在Android中,有两种不同的HttpClient类,一个是Java.net包中的:HttpURLConnection,它设置代理代码如下:
Proxy proxy=new Proxy(java.net.Proxy.Type.HTTP,new InetSocketAddress("10.0.0.172",80));
HttpURLConnection connection=(HttpURLConnection) url.openConnection(proxy);
还有一个是Apache的HttpClient:
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpHost proxy = new HttpHost("10.0.0.172"
, 80);
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
proxy);
转载于:https://www.cnblogs.com/abob/archive/2009/06/29/1513345.html