0

I want to connect with my web API, its URL is http://localhost:55154/, with android emulator.

AsyncHttpClient client = new AsyncHttpClient();

client.get("http://10.0.2.2:55154/api/values", new AsyncHttpResponseHandler() {    
    @Override
    public void onSuccess(String response) {
        System.out.println(response);
    }
});

I'm getting no response, however, when I connect to google.pl I'm getting a proper response.
I have tried multiple variants with the localhost address, but none is working.

Im using this liblary for my async connection: http://loopj.com/android-async-http/

UPDATE:

When I'm running my program I'm getting the following error from the LogCat

07-17 08:58:26.495: E/Trace(879): error opening trace file: No such file or directory (2)

However I am able to conect with http://localhost:55154/api/values via my browser.

Samoth
  • 1,691
  • 17
  • 24
Michal
  • 11
  • 1
  • 4

2 Answers2

0

use the IP address 10.0.2.2 not 10.0.0.2

reference http://developer.android.com/tools/devices/emulator.html#networkaddresses

Onur A.
  • 3,007
  • 3
  • 22
  • 37
  • I had 10.0.2.2 before, i posted wrong code because i was changing it some many times. Thanks anyway. – Michal Jul 16 '13 at 13:48
0

Use like this http://10.0.2.2:55154/ to connect with your port address

Matt
  • 74,352
  • 26
  • 153
  • 180
Sampath Kumar
  • 4,433
  • 2
  • 27
  • 42