• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Problem Trying To Access URL

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a servlet running, working OK with my browser.
The servlet is based on GET requests only.

I created an Android project.
Added to AndroidManifest.xml this: <uses-permission android:name="android.permission.INTERNET" />

Than I found on the net, this type of function:

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

Which works fine using regular Java project, but when I try to use it on my Android project, I get an exception ^ .

I'm trying to use a GET request in order to get a String returned to me.
 
Marshal
Posts: 27590
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you consider reading the exception to see what it said?
 
Miko Diko
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Did you consider reading the exception to see what it said?


I googled and found out about LogCat..

I set LogCat up, and while the program was running in Debug, the log in LogCat didn't show anything unusual, but when I closed the Android Emulator window, it showed this :

[2011-07-26 21:18:33 - Logcat]device not found
com.android.ddmlib.AdbCommandRejectedException: device not found
at com.android.ddmlib.AdbHelper.setDevice(AdbHelper.java:736)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:373)
at com.android.ddmlib.Device.executeShellCommand(Device.java:284)
at com.android.ddmuilib.logcat.LogPanel$3.run(LogPanel.java:527)
 
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic