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 {
}