我还更改了截击的默认策略,但是它对我不起作用,仍然在数据库中显示重复记录。
stringRequest.setRetryPolicy(new DefaultRetryPolicy(20000, -1, 0));
StringRequest stringRequest = new StringRequest( Request.Method.POST, urlUpload, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Toast.makeText( context.getApplicationContext(), response, Toast.LENGTH_LONG ).show();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText( context.getApplicationContext(), error.toString(), Toast.LENGTH_LONG ).show();
}
}
) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
for(int i=0;i<paramsTit.length;i++){
params.put( paramsTit[i],param[i] );
}
return params;
}
};
stringRequest.setRetryPolicy(new DefaultRetryPolicy(20000, -1, 0));
RequestQueue requestQueue = Volley.newRequestQueue( context );
requestQueue.add( stringRequest );