2013-03-20 89 views
1

我正在开发一个android应用程序,我必须发布一个日期形式到HTTPs。Android HTTPS获取请求挂在响应= client.execute(请求);

首先,我尝试连接到该页面并执行一个GET请求,但应用程序正在对忌用:

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(); 
     } 
+0

为什么在发布请求时执行'findViewById()'操作? – 2013-03-20 09:23:44

+0

我只需要在我的应用中显示页面,以便我可以看到结果。 – 2013-03-20 09:25:23

+0

显示该页面? Android中的Page是什么意思? – 2013-03-20 09:27:36

回答