android网络连接httpGet,遇到java.net.UnknownHostException: Host is unresolved 异常

android 2.2 http网络连接遇到 java.net.UnknownHostException: Host is unresolved 异常,尝试下面写法

 

String httpUrl = "http://www.google.com.hk/ig/api?weather=Beijing";

HttpGet get = new HttpGet(httpUrl);
HttpResponse httpResponse = new DefaultHttpClient().execute(get); 

   //请求成功
   if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
   {
    //取得返回的字符串
    //String strResult = EntityUtils.toString(httpResponse.getEntity());
    InputStream input = httpResponse.getEntity().getContent();

      ...
   }
   else {
   }

 

 

你可能感兴趣的:(Android)