android-async-http icon indicating copy to clipboard operation
android-async-http copied to clipboard

onFailure(...) was not overridden, but callback was received

Open ghost opened this issue 10 years ago • 4 comments

logcat has warning W/JsonHttpRH﹕ onFailure(int, Header[], String, Throwable) was not overriden, but callback was received in my code. I haved try to solved and read this issued https://github.com/loopj/android-async-http/issues/944 but i can't solve it.

My code

AsyncHttpClient client = new AsyncHttpClient();
client.get(address, null, new JsonHttpResponseHandler() {
      @Override
      public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
               //Code
      }
      @Override
       public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONArray errorResponse) {
               Log.d(TAG , "onFailure : "+statusCode);
    }
});

ghost avatar Aug 29 '16 09:08 ghost

You have not overriden all methods of JsonHttpResponseHandler(). Check the documentation: https://github.com/loopj/android-async-http/blob/master/library/src/main/java/com/loopj/android/http/JsonHttpResponseHandler.java

dionisi avatar Sep 09 '16 14:09 dionisi

There are several onFailure methods each with different parameter sets. According to your log you need to override the one with the following parameters: (int, Header[], String, Throwable).

@Override
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
    Log.d(TAG , "onFailure : "+statusCode);
}

rustigano avatar May 01 '17 13:05 rustigano

How to solve it, explain

Mr-LYF avatar Mar 15 '18 12:03 Mr-LYF

@Mr-LYF override the methods you want to override, thats correct solution

smarek avatar May 23 '19 13:05 smarek