How to prevent Volley request from retrying?

后端 未结 4 935
春和景丽
春和景丽 2020-12-13 18:54

I post a JsonRequest to a server. The server is slow and Volley tends to make multiple calls to the slow server because it didn\'t get a response from the first request (sin

4条回答
  •  旧时难觅i
    2020-12-13 19:21

    To stop Volley from retrying a request, simply set the retry policy of the request to a DefaultRetryPolicy with maxNumRetries being 0:

    myRequest.setRetryPolicy(new DefaultRetryPolicy(
        DefaultRetryPolicy.DEFAULT_TIMEOUT_MS,
        0,  // maxNumRetries = 0 means no retry
        DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    

提交回复
热议问题