jsonRequest.setRetryPolicy(new CustomRetryPolicy(REQUEST_TIMEOUT, MAX_RETRIES, BACKOFF_MULTIPLIER));
int socketTimeout = 5000;//30 seconds - change to what you want RetryPolicy policy = new DefaultRetryPolicy(socketTimeout, 2, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT); jsObjRequest.setRetryPolicy(policy); CustomVolleyRequestQueue.getInstance(mContext).getRequestQueue().add(jsObjRequest);
jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(50000,DefaultRetryPolicy.DEFAULT_MAX_RETRIES,DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
request.setRetryPolicy(new DefaultRetryPolicy(mBuilder.timeOut , mBuilder.retry, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); request.setTag(mBuilder.tag);
private void pullUpdateInfo() { //用Volley请求服务器最新的版本信息 JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(AUTO_UPDATE_SERVER_ADDRESS, null, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject jsonObject) { paserJsonData(jsonObject); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { volleyError.printStackTrace(); afterUpdate.toDoAfterUpdate(); } }); //设置超时时间,以及重复请求次数 jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(500, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); //设置Tag jsonObjectRequest.setTag(AUTO_UPDATE_SERVER_ADDRESS); //添加到请求队列里面 MyApplication.getRequestQueue().add(jsonObjectRequest); }
request.setRetryPolicy(new DefaultRetryPolicy(new_request_timeout, new_request_max_retry, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); requestQueue.add(request); } else { JsonObjectRequest request = new JsonObjectRequest(url, postData, requestFuture, requestFuture); request.setRetryPolicy(new DefaultRetryPolicy(new_request_timeout, new_request_max_retry, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); requestQueue.add(request);