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?
Asked
Active
Viewed 793 times
1
-
What do you mean to achieve response code 200?. You will get it once everything is correct i meant that proper authentication, parameters, request type etc – iSrinivasan27 May 23 '16 at 08:05
-
what type of request are you using – kalin May 23 '16 at 20:37
1 Answers
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