我正在开发一个 android 应用程序,我必须在其中将日期形式发布到 HTTPS。
首先,我尝试连接到页面并执行获取请求,但应用程序被挂起:
response = client.execute(request);
.
LogCat 或控制台中没有错误消息。
这是正确的方法吗,有更好的方法吗?.
HttpURLConnection http = null;
String urlStr = "https://www.hilan.co.il/";
URL url;
HttpResponse response = null;
try {
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
request.setURI(new URI(urlStr));
response = client.execute(request);
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
WebView responseText=(WebView) findViewById(R.id.webView1);
responseText.loadData(EntityUtils.toString(resEntity),"text/html", "UTF-8");
}
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}