In my android application I have to do some http request using android volley. If my request succeed everything's ok, the problem arise when I get an error and this error has status code 401. In this case I want to make some stuff and repeat the same request, same url and same parameters. Is there an official way to do that? If not, how can I get my params from error?
StringRequest req = new StringRequest(method, URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response){
//VolleyLog.v("Response:%n %s", response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
NetworkResponse response = error.networkResponse;
if(response.statusCode == 401){
//make some stuff...
//here i want to resend my request
}
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
//get headers
}
@Override
public Map<String, String> getParams() throws AuthFailureError {
//get params
}
};
// add the request object to the queue to be executed
ApplicationController.getInstance().addToRequestQueue(req);
Any help would be appreciated.