我开发了执行一些不同httpGet的应用程序。 我执行一个适用于Android 6但在API 22和21上工作的URL并不能正常工作并告诉我这个错误: javax.net.ssl.SSLPeerUnverifiedException:没有对等证书 代码是这样的:
private class HttpGetTask12 extends AsyncTask<Void, Void, String> {
GPSTracker gpsTracker = new GPSTracker(getActivity());
ProgressDialog dialog;
Double lat = gpsTracker.getLatitude();
Double lon = gpsTracker.getLongitude();
HttpClient mClient = new DefaultHttpClient();
Context context;
public HttpGetTask12(Context context) {
this.context = context;
}
// ClusterManager<Car2GoClusterItem> mClusterManager;
@Override
protected void onPreExecute() {
super.onPreExecute();
dialog = new ProgressDialog(getActivity());
dialog.setMessage(getResources().getString(R.string.caricamento));
dialog.show();
dialog.setCancelable(false);
}
@Override
protected String doInBackground(Void... params) {
String SERVICE_URL = "https://api.hailoapp.com/drivers/near?latitude="+lat+"&longitude="+lon;
String URL = SERVICE_URL;
//HttpGet request_ = new HttpGet(URL);
HttpGet request_ = new HttpGet(URL);
request_.setHeader("Authorization", "token " + token);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
Log.d("Hailo_url", ":" + URL);
try {
return mClient.execute(request_, responseHandler);
} catch (ClientProtocolException exception) {
exception.printStackTrace();
} catch (IOException exception) {
exception.printStackTrace();
}
return null;
}
为什么我只在API 22和21上出现此错误,但在ANdroid 6上却没有。 我如何解决这个问题? 感谢