为什么这说明书在java中,但严重在Android的工作呢? [英] why this statment work well in java but badly in android?
本文介绍了为什么这说明书在java中,但严重在Android的工作呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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.
推荐答案
有没有这样的构造方案,正如你所看到的这里有<一个href="http://developer.android.com/reference/org/apache/http/conn/scheme/Scheme.html#Scheme%28java.lang.String,%20org.apache.http.conn.scheme.SocketFactory,%20int%29"相对=nofollow>类似的一个可以使用,但。这里有一个例子从链接的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);
这篇关于为什么这说明书在java中,但严重在Android的工作呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文