You are trying to connect on your Android device to a local server
listening on port 8080. Of course there is  no server listening on
this port because the server runs on a different machine. Try to make
sure that you use the correct server IP address instead the loopback
address.

Are you running this on a real device or on the emulator?

--
Roman Baumgaertner
Sr. SW Engineer-OSDC
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.

On Aug 25, 5:50 am, Small World <[email protected]> wrote:
> I am trying to let Android connect to my Google App. While I have
> tried many kinds way of connection, somehow I failed all. The error is
> java.net.Connection.Exception:localhost/127.0.0.1:8080 - Connection
> refused.
>
> Hope someone can help me fix this problem.
>
> My one method is as follows:
> --------------------------------------------------
>     private String getHttpResponse(String location) {
>         String result = null;
>         URL url = null;
>                   try {
>                       url = new URL(location);
>                      } catch (MalformedURLException e) {
>                      result = "\n1:" + e.toString();
>                     }
>      if (url != null) {
>         try {
>          HttpURLConnection urlConn = (HttpURLConnection)
> url.openConnection(); //使用HttpURLConnection打开连接
>          BufferedReader in = new BufferedReader(new InputStreamReader
> (urlConn.getInputStream()));//为输出创建BufferedReader
>          String inputLine;
>          int lineCount = 0; // limit the lines for the example
>         while ((lineCount < 10) && ((inputLine = in.readLine()) !=
> null)) { //读Response中的数据
>                  lineCount++;
>                  result += "\n" + inputLine;
>         }
>         in.close();
>        urlConn.disconnect();
>       } catch (IOException e) {
>             result = "\n2:" +  e.toString();
>        }
>   } else {
>        result = " url NULL";
>        }
>       return result;
>    }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to