为什么这说明书在java中,但严重在Android的工作呢?说明书、严重、工作、java

2023-09-06 07:11:46 作者:三分淑女七分浪

SchemeRegistry supportedSchemes = new SchemeRegistry();
supportedSchemes.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));

该声明在java中机器人的工作很好,但不好?我不得不添加httpclient_4.1.3.jar在我引用的依赖和Android的依赖。

This statement work well in java but badly in android? I had add httpclient_4.1.3.jar in my referenced dependencies and android dependencies.

推荐答案

有没有这样的构造方案,正如你所看到的这里有类似的一个可以使用,但。这里有一个例子从链接的Javadoc页面:

There is no such constructor for Scheme, as you can see here There is a similar one you can use though. Here is an example from the linked Javadoc page:

Scheme https = new Scheme("https", new MySecureSocketFactory(), 443);
SchemeRegistry.DEFAULT.register(https);

还是要调整你的code到这一点:

Or to adapt your code to this:

Scheme http = new Scheme("http", PlainSocketFactory.getSocketFactory(), 80);
SchemeRegistry.DEFAULT.register(http);