Android HTTPS get请求挂起响应=client.execute(请求);
我正在开发一个android应用程序,在这个应用程序中,我必须将一个日期表单发布到HTTPs 首先,我尝试连接到页面并执行get请求,但应用程序被挂起:Android HTTPS get请求挂起响应=client.execute(请求);,android,https,Android,Https,我正在开发一个android应用程序,在这个应用程序中,我必须将一个日期表单发布到HTTPs 首先,我尝试连接到页面并执行get请求,但应用程序被挂起: response=client.execute(请求) LogCat或console中没有错误消息 这是正确的方法吗?有更好的方法吗? HttpURLConnection http = null; String urlStr = "https://www.hilan.co.il/"; URL url; HttpRespo
response=client.execute(请求)代码>
LogCat或console中没有错误消息
这是正确的方法吗?有更好的方法吗?
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();
}
原因是url错误,应该是 为什么在发布请求时要执行findViewById()
?我只需要在我的应用程序中显示页面,以便查看结果。是否显示页面?Android中的页面是什么意思?我指的是html页面的响应实体。如果你必须发布一个带有数据(带有参数)的表单,那么为什么要使用没有参数的GET请求?