AsyncHtt prequest POST不会触发回调(Android的异步HTTP通过循环J) [英] AsyncHttpRequest POST not triggering callbacks (android-async-http by loopj)

查看:256
本文介绍了AsyncHtt prequest POST不会触发回调(Android的异步HTTP通过循环J)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用循环J的异步HTTP库发送POST到服务器。下面code是pretty的标准,但我不能让它的工作。

I'm trying to send a POST to a server using loopj's async http library. The following code is pretty standard but I can't get it to work.

我已经调试了不少,并检查以下内容:

I have debugged quite a bit and have checked the following:

  • 的URL是正确的。
  • 的PARAMS是正确的,它们被正确地存储到PARAMS变量。

看来,当的Htt presponse响应= client.execute(请求,上下文); 被称为 AsyncHtt prequest .makeRequest()不包含任何PARAMS请求:

It appears that when HttpResponse response = client.execute(request, context); is called in AsyncHttpRequest.makeRequest() the request doesn't contain any params:

编辑:细算codeA一点似乎post数据可能被包含在实体或headergroup

EDIT : After looking at the code a little more it seems the POST params might be included in the entity or headergroup.

但真正的问题是,我没有得到任何的回调(参见下面的code)条。在 client.execute后的如果语句()通话不会被调用(断点未触发)。

But the real problem is that I don't get any of the callbacks (see code below). The if statement after the client.execute() call never gets called (the breakpoint isn't triggered).

RequestParams params = new RequestParams();
params.put("loginid", "user");
params.put("password", "pass");
params.put("deviceid", "deviceid");

AsyncHttpClient client = new AsyncHttpClient();
client.post(MDSettings.BASE_URL + "/user/login", params, new AsyncHttpResponseHandler() {
    @Override
    public void onSuccess(String response) {
        Log.d(MDSettings.TAG, "MDConnectionManager - login - response: " + response);
        singleton.connectionSuccessful(response, returnIndex);
    }

    @Override
    public void onFailure(Throwable error, String content) {
        Log.d(MDSettings.TAG, "MDConnectionManager - login - content: " + content);
        singleton.connectionFailed("Login Failed", error.getMessage(), returnIndex);
    }
});

我使用这个lib中,因为它让我送,我以后会需要这个项目文件。如果有另一个lib中,做同样的事情(和实际工作),我不会有事和我在一起。

I'm using this lib because it lets me send files which I'll need later into this project. If there is another lib that does the same thing (and actually works) that'd be fine with me.

我的问题是:为什么我没有拿到任何回调,我该如何解决这一问题?告诉我,当事情不清楚,我会尝试更深入讲解。

My question is: Why don't I get any callbacks and how can I fix this? Tell me when something isn't clear and I'll try to explain in more depth.

推荐答案

看来我的 android.permission.INTERNET对项目被从清单文件中删除。加入后再次一切都如预期。每当一些不工作,我会检查我的权限。

It seems my android.permission.INTERNET entry was removed from the manifest file. After adding it again everything worked as expected. Every time something doesn't work I'll be checking my permissions.

这篇关于AsyncHtt prequest POST不会触发回调(Android的异步HTTP通过循环J)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆