您的位置:首页 > 理论基础 > 计算机网络

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

2011-03-09 15:48 525 查看
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 {
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐