I am using Loopj to get a request and response. But it seems that callback method is not called properly if internet connection with no data. When I click a listview its execute below code:
AsyncHttpClient client = new AsyncHttpClient();
client.get("http://www.google.com", new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
System.out.println("onSuccess");
}
@Override
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
System.out.println("onFailure");
}
});
Problem is that if internet connected but with no data then onFailure() is not calling even after timeout settings.
I have tried with below timeout settings in client:
client.setTimeout(5000);
or
client.setConnectTimeout(5000);
or
client.setResponseTimeout(5000);
or
client.setMaxRetriesAndTimeout(5,1000);
None of these forcing to call onFailure(). My question is there any way to call onFailure() if internet connection with no data or any other callback available in Loopj which fired after timeout?