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 {
}
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程序[genymotion]连接网络错误:java.net.unknownhostexception:unable to resolve host
- 首次测试android程序连接网络错误:java.net.unknownhostexception:unable to resolve host
- 首次测试android程序连接网络错误:java.net.unknownhostexception:unable to resolve host
- android程序连接网络错误:java.net.unknownhostexception:unable to resolve host
- android开发 java.net.UnknownHostException:URL 异常解决办法
- InetAddress.getLocalHost() java.net.UnknownHostException 异常
- android java.net.UnknownHostException:异常
- java异常之Couldn't get host name! [See nested exception: java.net.UnknownHostException: ceshi: ceshi:
- 代理抛出异常错误: java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException:
- java.net.UnknownHostException 异常处理
- Failed to get local hostname java.net.UnknownHostException
- android java.net.UnknownHostException: Unable to resolve host "...": No address associated 错误
- android java.net.UnknownHostException: Unable to resolve host "...": No address associated 错误
- linux java.net.UnknownHostException异常
- java.net.UnknownHostException 异常处理
- org.quartz.SchedulerException: Couldn't get host name! [See nested exception: java.net.UnknownHostException:
- Android 访问网络时抛 UnknownHostException异常
- 解决mac OS X 下出现的 java.net.UnknownHostException 异常
- Jmeter 遇到的问题:rc="Non HTTP response code: java.net.NoRouteToHostException" rm="Non HTTP response mess
- java连接redis/redis集群报Caused by: java.net.UnknownHostException: 主机名: Name or service not k