Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android截击Post请求_Android_Android Volley - Fatal编程技术网

Android截击Post请求

Android截击Post请求,android,android-volley,Android,Android Volley,我已经通过截击实现了post请求。但是它有一些奇怪的行为。我得到的响应是服务器没有响应,但这些post数据仍然被插入数据库两次。 这些参数是从edittext字段中获取的简单字符串类型的数据。有关此参数的任何帮助信息 StringRequest stringRequest = new StringRequest(Request.Method.POST, GlobalConfig.ADD_ACTIVITY_URL, new Response.Listener<

我已经通过截击实现了post请求。但是它有一些奇怪的行为。我得到的响应是服务器没有响应,但这些post数据仍然被插入数据库两次。 这些参数是从edittext字段中获取的简单字符串类型的数据。有关此参数的任何帮助信息

    StringRequest stringRequest = new StringRequest(Request.Method.POST, GlobalConfig.ADD_ACTIVITY_URL,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    progressDialog.dismiss();
                    Log.e("response", response);                               

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }


                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    progressDialog.dismiss();
                    GlobalCommonMethods.handleErrorResponse(ActivityTeacher.this,error,"Server not responding !!!");
                }
            }) {
        @Override
        protected Map<String, String> getParams() {
            Map<String, String> arguments = new HashMap<String, String>();
            arguments.put("teacher_id", "ds";

            arguments.put("action", "comment");

            arguments.put("user_type", "teacher");
            return arguments;
        }
    };
    RequestQueue requestQueue = Volley.newRequestQueue(this);
    requestQueue.add(stringRequest);
StringRequest StringRequest=新的StringRequest(Request.Method.POST、GlobalConfig.ADD\u ACTIVITY\u URL、,
新的Response.Listener(){
@凌驾
公共void onResponse(字符串响应){
progressDialog.disclose();
Log.e(“响应”,响应);
}捕获(JSONException e){
e、 printStackTrace();
}
}
},
新的Response.ErrorListener(){
@凌驾
公共无效onErrorResponse(截击错误){
progressDialog.disclose();
GlobalCommonMethods.handleErrorResponse(ActivityTeacher.this,错误,“服务器没有响应!!!”;
}
}) {
@凌驾
受保护的映射getParams(){
映射参数=新的HashMap();
参数。put(“教师id”、“ds”;
论点。提出(“行动”、“评论”);
参数.put(“用户类型”、“教师”);
返回参数;
}
};
RequestQueue RequestQueue=Volley.newRequestQueue(this);
添加(stringRequest);

我猜您缺少了
catch(){…}
之前尝试{…}
。下面是我的意思示例:

StringRequest stringRequest = new StringRequest(Request.Method.POST, GlobalConfig.ADD_ACTIVITY_URL,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {

                    try {

                    Something here...

                     } catch (JSONException e) {

                    Something here ...

                     }
                }
            }, ...
StringRequest StringRequest=新的StringRequest(Request.Method.POST、GlobalConfig.ADD\u ACTIVITY\u URL、,
新的Response.Listener(){
@凌驾
公共void onResponse(字符串响应){
试一试{
这里有些东西。。。
}捕获(JSONException e){
这里有些东西。。。
}
}
}, ...

你能发布截击错误吗?