1

My app uses volley library for networking operation. I want to get the response code (that may be 200 or 401) inside onResponse() method. How can i achieve that?

Matt
  • 14,906
  • 27
  • 99
  • 149
Joy Mello
  • 11
  • 1

1 Answers1

1

you can make a custom request and override:

@Override
protected Response<T> parseNetworkResponse(NetworkResponse response) {
    if (response.statusCode == 200) {
        //do smth
    } else if (response.statusCode == 401) {
        //do smth else
    }
    return super.parseNetworkResponse(response);
}

this way you will still receive the same data in your callbacks but special cases typical for the request you can handle within the request itself.

kalin
  • 3,546
  • 2
  • 25
  • 31