2013-03-20 88 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

回答