我正在使用以下代码使用 HTTP 代理:
DefaultHttpClient client = new DefaultHttpClient();
HttpHost proxy = new HttpHost(proxyHost, proxyPort, "http");
client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
这适用于几个运行 android 2.3 及更高版本的 android 设备。但是,当我在运行 android 2.2.2 的 HTC 愿望上尝试此操作时,出现以下异常:
java.lang.IllegalArgumentException
java.net.InetSocketAddress.<init>(InetSocketAddress.java:98)
java.net.InetSocketAddress.<init>(InetSocketAddress.java:89)
org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.<init>(OpenSSLSocketImpl.java:238)
org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImplWrapper.<init>(OpenSSLSocketImplWrapper.java:35)
org.apache.harmony.xnet.provider.jsse.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:83)
de.bahn.android.ris.communication.http.EasySSLSocketFactory.createSocket(EasySSLSocketFactory.java:136)
org.apache.http.impl.conn.DefaultClientConnectionOperator.updateSecureConnection(DefaultClientConnectionOperator.java:225)
org.apache.http.impl.conn.AbstractPoolEntry.layerProtocol(AbstractPoolEntry.java:302)
org.apache.http.impl.conn.AbstractPooledConnAdapter.layerProtocol(AbstractPooledConnAdapter.java:146)
org.apache.http.impl.client.DefaultRequestDirector.establishRoute(DefaultRequestDirector.java:623)
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:352)
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
有没有人见过这种行为?谢谢!