我有一个问题,在慢速网络上的截击POST请求。每当我在我的LogCat中看到BasicNetwork.logSlowRequests
时,我的POST请求就会被执行两次或更多,从而对一个请求执行多个(2个或更多)POST。我已经将重试策略设置为0,但它没有帮助。
这是我的LogCat
03-16 01:31:35.674: D/Volley(5984):19807 BasicNetwork.logSlowRequests: request=< http://[myserver]/api/places的HTTP响应](http://[myserver]/api/places) 0xfa7d0c33 NORMAL 1> lifetime=3824,size=313,rc=200,retryCount=0 03-16 01:31:35.704: D/Volley(5984):1 Request.finish: 3853 ms:http://[myserver]/api/places](http://[myserver]/api/places) 0xfa7d0c33 NORMAL 1
这是我的代码
JSONObject body = new JSONObject();
try {
body.put(PROTO_BODY_AUTHORIZATION, Sessions.getActiveSession().getToken());
} catch (JSONException e) {
e.printStackTrace();
}
JsonObjectRequest request = new JsonObjectRequest(
Request.Method.POST,
context.getResources().getString(R.string.server_address) + "/places",
body,
callback,
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(context, error.getMessage(), Toast.LENGTH_LONG).show();
}
}
);
request.setRetryPolicy(
new DefaultRetryPolicy(
DefaultRetryPolicy.DEFAULT_TIMEOUT_MS,
0,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
getRequestQueue().add(request);
请帮帮忙,我正在拼命寻找解决这个问题的办法。
https://stackoverflow.com/questions/22428343
复制相似问题