Thursday, June 30, 2011

[android-developers] Re: Java.net.UnknownHostException using httpGet on Android

You already have the right permission, good. But you still need to 1)
double check that the host data is in the right format: the least
discrepancy will cause that exception and 2) make sure you HAVE
internet connectivity. No firewalls in the way? WiFi turned on?

On Jun 24, 7:09 am, My Email <connectmyem...@gmail.com> wrote:
> Exception  :
>
> Java.net.UnknownHostException using httpGet on Android
>
> String requestTpServer = "www.google.com";
> HttpClient client = new DefaultHttpClient();
> HttpResponse response = null ;
>
> try {
>
>   HttpGet get = new HttpGet(requestToServer);
>
>   response = client.execute(getm);      ///Problem here
>
> } catch (ClientProtocolException e) {
>
>   e.printStackTrace();
>
> } catch (IOException e) {
>
>   e.printStackTrace();
>
> }
>
> String res = response.toString();
>
> I have already set      <uses-permission
> android:name="android.permission.INTERNET" />
>
> and also run String requestTpServer = "www.google.com";  in android
> emulater browser
>
> thanks

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment