@H_404_6@
我需要在几个区域使用loopj的SyncHttpClient.当我使用AsyncHttpClient时,请求成功返回.当我使用SyncHttpClient时,如此处接受的答案所示:
How to use loopJ SyncHttpClient for synchronous calls?,我在onFailure中遇到了一个断点. statusCode为0,errorResponse为null,throwable为java.io.IOException:未处理的异常:null.
这是相关的代码.我再次使用Async时效果很好:
buttonTest.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// AsyncHttpClient httpClient = new AsyncHttpClient();
SyncHttpClient httpClient = new SyncHttpClient();
httpClient.get("http://10.0.1.6:3000/home/test_endpoint",new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode,Header[] headers,JSONObject response) {
String stringResponse = response.toString();
}
@Override
public void onFailure(int statusCode,Throwable throwable,JSONObject errorResponse) {
String error = errorResponse.toString();
}
});
String temp = "got here";
}
});
我正在使用编译’com.loopj.android:android-async-http:1.4.9′