Man*_*uel 7 post android asynchronous loopj
我正在尝试使用loopj的异步http库向服务器发送POST .以下代码非常标准,但我无法使其工作.
我调试了很多,并检查了以下内容:
似乎HttpResponse response = client.execute(request, context);
在AsyncHttpRequest.makeRequest()
请求中调用时不包含任何参数:
编辑:看了一下代码后,似乎POST参数可能包含在实体或标题组中.
但真正的问题是我没有得到任何回调(见下面的代码).在if
后声明client.execute()
通话不会被调用(断点不会被触发).
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);
}
});
Run Code Online (Sandbox Code Playgroud)
我正在使用这个lib,因为它允许我将稍后需要的文件发送到这个项目中.如果有另一个lib做同样的事情(并且实际上有效),那对我来说没问题.
我的问题是:为什么我没有得到任何回调,我该如何解决这个问题?当事情不明确时告诉我,我会尝试更深入地解释.