Get Request Problem In Android

Discussion in 'Android Tablet Discussions' started by Ya2, Jul 25, 2011.

  1. Ya2

    Ya2 Member

    Joined:
    Jun 27, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    60
    I use Eclipse and when I try to connect to my servlet using 'normal' Java, it works fine.

    But when I paste the same code in my Android project, I get an empty String as a response.

    Why ?

    Code: (BASE_URL = url before (including) the '?' , inputURL is the rest of the URL)

    private static String accessURL(String inputURL) throws IOException{
    String inputLine = "";
    try {
    URL oracle = new URL(BASE_URL + inputURL);
    URLConnection yc = oracle.openConnection();
    BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
    inputLine = in.readLine();
    in.close();
    } catch (MalformedURLException e) {
    e.printStackTrace();
    } finally{
    return inputLine;
    }
    }

    And calling the function:

    accessURL("type=1");
     
  2. Ya2

    Ya2 Member

    Joined:
    Jun 27, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    60
    Anyone ? :(
     

Share This Page