RT, Google后有的说是 将超时时间设置为0, 但是还是会重试提交,

解决方案如下:

static HurlStack stack =  new HurlStack(){
        @Override
        protected HttpURLConnection createConnection(URL url) throws IOException {
            HttpURLConnection con = super.createConnection(url);
            //主要是这行代码, 貌似是因为HttpClient的bug
            con.setChunkedStreamingMode(0);
            return con;
        }
    };
static RequestQueue mQueue = Volley.newRequestQueue(context, stack);

//....
StringRequest req = new StringRequest(...);
req.setRetryPolicy(new DefaultRetryPolicy(20*1000, 0, 1.0f));
mQueue.add(req);

如果提交错误, 最好是取消掉该请求

mQueue.cancelAll(tag);

 

相关文章:

  • 2021-06-17
  • 2021-04-27
  • 2022-12-23
  • 2021-11-12
  • 2021-12-01
  • 2021-06-26
  • 2022-12-23
猜你喜欢
  • 2021-11-17
  • 2022-12-23
  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案