File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Android and the fly likes Problem Trying To Access URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Problem Trying To Access URL" Watch "Problem Trying To Access URL" New topic

Problem Trying To Access URL

Miko Diko

Joined: Jun 27, 2011
Posts: 5
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();
} catch (MalformedURLException e) {
} 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.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19869

Did you consider reading the exception to see what it said?
Miko Diko

Joined: Jun 27, 2011
Posts: 5
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 device not found
I agree. Here's the link:
subject: Problem Trying To Access URL
It's not a secret anymore!