Android Volley makes 2 requests to the server when retry policy is set to 0 Android Volley makes 2 requests to the server when retry policy is set to 0 android android

Android Volley makes 2 requests to the server when retry policy is set to 0


The DefaultRetryPolicy.class's hasAttemptRemaining() class looks like this:

protected boolean hasAttemptRemaining() {    return this.mCurrentRetryCount <= this.mMaxNumRetries;}

From what I can see, setting the maxNumRetries to 0 will still make that return true if it hasn't done a retry yet.

I fixed it with a

request.setRetryPolicy(new DefaultRetryPolicy(0, -1, 0);


I use this to set the no-repeat policy:

    myRequest.setRetryPolicy(new DefaultRetryPolicy(0,            DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));


Just set timeout to 20second or more as you want,and retry to 0

req.setRetryPolicy(new DefaultRetryPolicy(20 * 1000, 0,  DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));