1. ホーム
  2. アンドロイド

AndroidでDefaultHttpClientを使用してWapネットワークにアクセスする場合

2022-03-02 15:01:56
In Android, there are two different HttpClient classes, one is in the Java.net package.
HttpURLConnection, which sets up the proxy code as follows.


Proxy proxy=new Proxy(java.net.Proxy.Type.HTTP,new InetSocketAddress("10.0.0.172",80));
HttpURLConnection connection=(HttpURLConnection) url.openConnection(proxy);




There is also Apache's HttpClient.


DefaultHttpClient httpclient = new DefaultHttpClient(); HttpHost proxy = new HttpHost("10.0.0.172", 80); httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpHost proxy = new HttpHost("10.0.0.172", 80);
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);