<script type="text/javascript"> var m = window.__blog.preRenderPosts; if (m) { m(); } </script>
2009-06-29 16:34 by cppguy, 344 visits, 网摘 , 收藏 , 编辑 访问中国移动的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);