请求我的php文件时,Android Volley双发

时间:2019-05-21 00:04:58

标签: android mysql android-volley

我还更改了截击的默认策略,但是它对我不起作用,仍然在数据库中显示重复记录。

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 );

0 个答案:

没有答案