Good day,
In this moment I'm developing an app that use a webservice of mode Async, but I have some problems with it. I need use the webservice of mode synchronous for continue with my principal thread without any problem.
Thanks so much!!!
Good day,
In this moment I'm developing an app that use a webservice of mode Async, but I have some problems with it. I need use the webservice of mode synchronous for continue with my principal thread without any problem.
Thanks so much!!!
Same way as we use async-http-client for loopj, but it will block the UI till completion.
SyncHttpClient syncHttpClient = new SyncHttpClient();
syncHttpClient.setTimeout(timeout);
syncHttpClient.post(url, params, responseHandler);
syncHttpClient .post("http://example.com", params, new JsonHttpResponseHandler() {
@Override
public void onStart() {
// you can do something here before request starts
}
@Override
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
// success logic here
}
@Override
public void onFailure(int statusCode, Header[] headers, Throwable e, JSONObject errorResponse) {
// handle failure here
}
});