LoopJ AndroidAsyncHttp 在 OnFailure 中返回响应
LoopJ AndroidAsyncHttp is returning response in OnFailure
我是 AndroidAsyncHttp 的新手。
我创建了一个 class httptester :
private static AsyncHttpClient client = new AsyncHttpClient();
public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
client.get(getAbsoluteUrl(url), params, responseHandler);
}
public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
client.post(getAbsoluteUrl(url), params, responseHandler);
}
private static String getAbsoluteUrl(String relativeUrl) {
return relativeUrl;
}
并在我的 activity 中执行了以下操作:
RequestParams params = new RequestParams();
params.put("FTID", HTTPRequestUserAuthentication.AppID);
params.put("UUID", MainActivity.uuid);
params.put("TYPE", "11");
params.put("DateTimeStamp", DateTimeStamp);
params.put("SDFVersionNb", SDFVersionNb);
httptester.post(MainActivitySharedPref.GetValue(MyApplication.getContext(), "WebService_URL")+MyApplication.getContext().getResources().getString(R.string.url_get_user_data), params,new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, String responseString) {
super.onSuccess(statusCode, headers, responseString);
Log.e(TAG, "sucess: " + responseString);
}
@Override
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
Log.e(TAG, "failure: " + responseString);
Log.e(TAG, "failurecode: " + statusCode);
super.onFailure(statusCode, headers, responseString, throwable);
}
});
调用客户端后,返回了正确的响应,但它是在 OnFailure 中返回的,而不是在 OnSuccess 中返回的。我还在 onfailure 中打印了状态代码,它是 200,应该没问题。
如有任何帮助,我们将不胜感激。
所以你打电话提出要求
new JsonHttpResponseHandler()
但是你需要
new AsyncHttpResponseHandler()
我是 AndroidAsyncHttp 的新手。
我创建了一个 class httptester :
private static AsyncHttpClient client = new AsyncHttpClient();
public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
client.get(getAbsoluteUrl(url), params, responseHandler);
}
public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
client.post(getAbsoluteUrl(url), params, responseHandler);
}
private static String getAbsoluteUrl(String relativeUrl) {
return relativeUrl;
}
并在我的 activity 中执行了以下操作:
RequestParams params = new RequestParams();
params.put("FTID", HTTPRequestUserAuthentication.AppID);
params.put("UUID", MainActivity.uuid);
params.put("TYPE", "11");
params.put("DateTimeStamp", DateTimeStamp);
params.put("SDFVersionNb", SDFVersionNb);
httptester.post(MainActivitySharedPref.GetValue(MyApplication.getContext(), "WebService_URL")+MyApplication.getContext().getResources().getString(R.string.url_get_user_data), params,new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, String responseString) {
super.onSuccess(statusCode, headers, responseString);
Log.e(TAG, "sucess: " + responseString);
}
@Override
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
Log.e(TAG, "failure: " + responseString);
Log.e(TAG, "failurecode: " + statusCode);
super.onFailure(statusCode, headers, responseString, throwable);
}
});
调用客户端后,返回了正确的响应,但它是在 OnFailure 中返回的,而不是在 OnSuccess 中返回的。我还在 onfailure 中打印了状态代码,它是 200,应该没问题。
如有任何帮助,我们将不胜感激。
所以你打电话提出要求
new JsonHttpResponseHandler()
但是你需要
new AsyncHttpResponseHandler()