我正在查看一些带有教程的页面,以了解如何从 url 获取 XML 并在手机上显示其中的数据,但我只找到了 http 连接。
我需要从 url 获取数据,但我无法使用 http 连接到服务器 我需要使用 https
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("https:...");
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
line = EntityUtils.toString(httpEntity);
line = con.getResponseMessage();
//con.getResponseMessage();
} catch (UnsupportedEncodingException e) {
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
} catch (MalformedURLException e) {
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
} catch (IOException e) {
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
}
如何更改此片段以使用 https?有没有从 https 获取 xml 的教程?