Actually that's is from the page you linked http://loopj.com/android-async-http/ . Theses callbacks are executed in the UI thread but the actual request is being processed in another thread.
AsyncHttpClient client = new AsyncHttpClient();
client.get("http://www.google.com", new AsyncHttpResponseHandler() {
@Override
public void onStart() {
// called before request is started
}
@Override
public void onSuccess(int statusCode, Header[] headers, byte[] response) {
// called when response HTTP status is "200 OK"
}
@Override
public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {
// called when response HTTP status is "4XX" (eg. 401, 403, 404)
}
@Override
public void onRetry(int retryNo) {
// called when request is retried
}
});
In your Activity's onStop() you should call AsyncHttpClient's cancelAllRequests(Context context, boolean mayInterruptIfRunning) method to cancel all the active and pending requests.
client.cancelAllRequests(this, true);
This should ensure that the callbacks of your requests are never called and then save yourself from non trivial network usage and save yourself from IllegalStateExceptions.