android 4模拟器无法与localhost连接

时间:2013-07-16 13:39:53

标签: android api localhost emulation loopj

我希望使用Android模拟器连接我的网络API,其网址为http://localhost:55154/

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);
    }
});

但是,当我连接到google.pl时,我没有得到任何回复。我得到了正确的答复。
我已尝试使用localhost地址的多个变体,但没有一个正在运行。

我使用此liblary进行异步连接: http://loopj.com/android-async-http/

更新

当我运行我的程序时,我从LogCat收到以下错误

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

但是我可以通过浏览器与http://localhost:55154/api/values保持一致。

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

使用此http://10.0.2.2:55154/来连接您的端口地址