Android Volley double post when have slow request

后端 未结 18 2685
生来不讨喜
生来不讨喜 2020-11-28 04:06

I have a problem with Volley POST request on slow network. Everytime I see BasicNetwork.logSlowRequests in my LogCat, my POST request is executed twice or more

18条回答
  •  [愿得一人]
    2020-11-28 04:44

    This works for me.

    public class MyRetryPolicyWithoutRetry implements RetryPolicy
    {
        @override
        public int getCurrentTimeout()
        {
            return CONNECTION_TIME_OUT; /200000/
        }
    
        @Override
        public int getCurrentRetryCount()
        {
            return 0;
        }
    
        @Override
        public void retry(VolleyError error) throws VolleyError
        {
            throw(error);
        }
    }
    

    To use:

    request.setRetryPolicy(new MyRetryPolicyWithoutRetry());
    

提交回复
热议问题