进行客户端https请求遇到问题:
Android: Exception “java.lang.IllegalStateException: Scheme 'https' not registered”
参考解决方案:http://stackoverflow.com/questions/15173228/android-exception-java-lang-illegalstateexception-scheme-https-not-register#comment21394458_15176565
原因是为进行https请求注册。
解决方案:
1.删除注册:
// client = new DefaultHttpClient(connman, params); client = new DefaultHttpClient(params);// 兼容https
2.添加注册:.
SchemeRegistry registry = new SchemeRegistry();
SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
registry.register(new Scheme("https", socketFactory, 8443));
http 类似错误,参考:
http://stackoverflow.com/questions/29340320/android-java-lang-illegalstateexception-scheme-http-not-registered-error-f