我在代码中使用了android Volley自定义请求, 我面临的问题是,即使请求成功,它也会多次请求服务器
RequestQueue mRequestQueue = Volley.newRequestQueue(ct);
JsonRequest sr = new JsonRequest(Request.Method.POST, url,new Response.Listener<JSONObject>() .......);
int socketTimeout = 10000; //10 seconds - change to what you want
sr.setRetryPolicy(new DefaultRetryPolicy(socketTimeout, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
mRequestQueue.add(sr);
这里是实作班的班级
class JsonRequest extends Request {
protected Response.Listener listener;
JsonRequest(int method, String url, Response.Listener listener, Response.ErrorListener errorListener)
{
super(method,url,errorListener);
this.listener = listener;
}
//Rest of the code
}