1

日付の形式をHTTPに投稿する必要があるAndroidアプリケーションを開発しています。

まず、ページに接続して 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();
        }  
4

1 に答える 1

0

理由は、URL がhttps://www.hilanet.co.ilである必要があるためです。

于 2013-03-21T07:50:26.540 に答える