Android HTTPS get请求挂起在response = client.execute(request);

时间:2013-03-20 09:11:57

标签: android https

我正在开发一个Android应用程序,我必须向HTTP发布一种日期形式。

首先,我尝试连接到该页面并执行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();
        }  

1 个答案:

答案 0 :(得分:0)

原因是网址错误应为https://www.hilanet.co.il