Volley Retry Request

I am currently testing a volleyball library. But when the request fails (404), it does not start again, or at least there are no errors. However, no data is available. Is this the correct way to retry the request if it failed?

Thanks in advance

req.setRetryPolicy(new DefaultRetryPolicy(5000,1,1.0f));
queue.add(req);

Using:

JsonObjectRequest req = null;
        for(int i=0;i<profielen.size();i++){
            final int pos = i;
             req = new JsonObjectRequest(Request.Method.GET, imageLocUrl, null, new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                        try {
                            setImageOnProfile(pos,response.get("thumbnail").toString());
                        } catch (JSONException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }


            }}, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                }
            });

            req.setRetryPolicy(new DefaultRetryPolicy(5000,1,1.0f));
            queue.add(req);
        }
+3
source share
1 answer

No, this is the wrong way.

Asides:

  • HTTP 404 is not a status code, I would expect a normal HTTP client code to be in a normal state to try again.

  • Most of all you like to receive an error message through the error listener, put a request, but your error listener is NOOP, so maybe you don’t notice?

  • ( http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.htmlhas OK descriptions of status code values.)

  • -: - , - , HTTP 401 HTTP 403. , AFAIK.

, 404 Volley onErrorResponse.

(Ficus: , RetryPolicy . , 503.)

+4

All Articles