安卓HTT prequest的java.net.UnknownHostException [英] android httprequest java.net.UnknownHostException

查看:418
本文介绍了安卓HTT prequest的java.net.UnknownHostException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要与Android http请求。

I want to make a http request with android.

是使用这样的:

void testHTTP()
 {
  HttpClient httpClient = new DefaultHttpClient();

  HttpUriRequest request = new HttpPost("http://www.google.com");

  try {
   HttpResponse response = httpClient.execute(request);

   //System.out.println("response protocol version: " + response.getProtocolVersion());
  } catch (ClientProtocolException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }

 }

我有上网权限设置我的清单文件。

I have the internet permission set in my manifest file.

我不断收到的java.net.UnknownHostException:www.google.com

我的最终目的IOS才能够调用Web服务。于是,我开始尝试ksoap2库和正确的URL,得到了相同的结果。

My final purpose ios to be able to invoke a web service. So, I initially tried the ksoap2 library and the proper url and got the same result.

我怀疑我有一些不好的环境无论是在我的应用程序,或在我的模拟器。

I suspect I have some bad setting either in my app or in my emulator.

您可以给我去哪里找一些指引?

can you give me some pointers on where to look?

这也将蜂类似的东西有用工作的例子。然后我可以检查,如果问题仍然存在,我想知道这是我的过错开发设置。

it would also bee useful a working example of something similar. then i could check and if the problem persists i would know that is my development setup at fault.

顺便说一句,我使用的是Mac雪豹与Eclipse和Android 2.2作为一个设置

btw, i am using mac snow leopard with eclipse and android 2.2 as a setup

感谢

关于

推荐答案

我有问题与模拟器所在的网络图标显示我有没有服务,我不能连接到Internet。通常情况下,重新启动模拟器固定它。有一次,我不得不创建一个新的模拟器设备。

I've had problems with the emulator where the network icon shows that I have no service, and I can't connect to the Internet. Usually, restarting the emulator fixed it. Once, I had to create a new emulator device.

请检查在模拟器/设备日志的线索。您可以使用在DDMS透视LogCat中查看在Eclipse中查看。

Do check for clues in the emulator/device logs. You can view them in Eclipse using the LogCat view in the DDMS perspective.

这篇关于安卓HTT prequest的java.net.UnknownHostException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆