It might be a simple question but I tested it in actual code and unable to judge the correct behaviour of setRetryPolicy()
function of Volley. Anyone please tell me the correct position of this statement to be written. Should I write this method call in onErrorResponse()
function or before entering the request into the queue?
Here is my code for bitmap image. I want 3 retries of 20 seconds after request timeout. Please suggest me the correct place for retry policy to be written and have I set the retry policy correct according to my need?
ImageRequest ir = new ImageRequest(url, new Response.Listener<Bitmap>() {
@Override
public void onResponse(Bitmap response) {
iv.setImageBitmap(response);
}
}, 0, 0, null, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
ir.setRetryPolicy(new DefaultRetryPolicy(20 * 1000, 2, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
}
});
mRequestQueue.add(ir);