1

Dear Ladys and Gentleman,

I did my homework, I've googled a lot and I think I know where the Problem can be located:

I want to fetch some simple JSON formated data from local Apache. When I start a

httpclient.execute(httppost)

... I receive (via printStackTrace()):

02-04 13:26:12.292: W/System.err(9606): java.net.UnknownHostException: http://localhost/JSON/request2.php
02-04 13:26:12.292: W/System.err(9606): java.net.UnknownHostException: http://127.0.0.1/JSON/request2.php
(after including the line "127.0.0.1 www.localhost.alt" to my Host file):
02-04 13:26:12.292: W/System.err(9606): java.net.UnknownHostException: http://www.localhost.alt/JSON/request2.php

I really need help. Have you any Ideas?

Greeting,

John


edit:

I made some research and found this article: Emulator Networking

As you can see localhost & 127.0.0.1 are reserved for the emulators loopbacks itself!

Thats why Dark is absolutely right when he said I have to use 10.0.2.2 there. Thanks a lot!

1
  • well... the request works fine if I put it into a basic browser address field :/ Commented Feb 4, 2012 at 13:40

1 Answer 1

6

It would have been nice if you posted your code along with the stacktrace.

But, Try using

  10.0.2.2 instead of localhost or 127.0.0.1

also add this

    <uses-permission android:name="android.permission.INTERNET"/>

to your AndroidManifest.xml

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks you both! Permission was already set. I don't know why, but 10.0.2.2 did work! Goddamn, if you would comment me this tricky fact I would even more thankful. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.