在移动设备上运行时,它运行正常。 但是在具有重新解决方案 * 480 * 854:mdpi * 的模拟器 5.4 FWVGA API 19 上运行时,会发生系统错误:
这是我的代码:
private void postTextDataToServerForLogin() {
try {
// url where the data will be posted
String postReceiverUrl = "https://www.jobs.com/";
// HttpClient
HttpClient httpClient = new DefaultHttpClient();
// post header
HttpPost httpPost = new HttpPost(postReceiverUrl);
// add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("username", email.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("password", password.getText().toString()));
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// execute HTTP post request
HttpResponse response = httpClient.execute(httpPost); //error in this line
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
responseStr = EntityUtils.toString(resEntity).trim();
String responseString = checkingServerResponse(responseStr);
if (responseString.equals("1")) {
finish();
} else {
}
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
我的logcat是:
W/System.err: javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
at com.android.org.conscrypt.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:146)
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:93)
at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:388)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:165)