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