排球得分错误

时间:2018-05-10 07:54:46

标签: android android-volley

我在排球时得到错误的回应,而另一方面邮递员得到正确的回应。请帮我解决问题所在。我从凌空得到的回应是“response = {”code“:1020,”message“:”不允许重复键“,”returnId“:null}” 在邮递员中它是“{     “code”:1089,“message”:“激活密钥通过电子邮件发送,请激活您的用户/设备”,“returnId”:438 }“

public void sendRegisterationReq("http://demo.innowi.com/v1/user/register",getJsonObject()) {



        RequestQueue queue = Volley.newRequestQueue(this);



        JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.POST,
                url, dataObj,
                new Response.Listener<JSONObject>() {

                    @Override
                    public void onResponse(JSONObject response) {

                        // Toast.makeText(context, "" + response.toString(), Toast.LENGTH_SHORT).show();
                        System.out.println("response= " + response.toString());
                        System.out.println(TAG + ":" + dataObj.toString());
                        try {
                            if (response.getString("code").equals("1020")){

                                Intent intent = new Intent(RegisterDeviceActivity.this,ActivateDeviceActivity.class);
                                startActivity(intent);

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


                    }
                }, new Response.ErrorListener() {

            @Override
            public void onErrorResponse(VolleyError volleyError) {

                String message = null;
                if (volleyError instanceof NetworkError) {
                    message = "Network error!";
                    Log.d(TAG,message);


                } else if (volleyError instanceof ServerError) {
                    message = "Server error!!";
                    Log.d(TAG,message);

                } else if (volleyError instanceof AuthFailureError) {
                    message = "Auth failure error!";
                    Log.d(TAG,message);

                } else if (volleyError instanceof ParseError) {
                    message = "Parsing error!";
                    Log.d(TAG,message);

                } else if (volleyError instanceof NoConnectionError) {
                    message = "No connection error!";
                    Log.d(TAG,message);

                } else if (volleyError instanceof TimeoutError) {
                    message = "timeout error !";
                    Log.d(TAG,message);

                }



            /*Toast.makeText(context, "error", Toast.LENGTH_SHORT).show();
            System.out.println(TAG + ":Error: " + volleyError.getMessage());
            System.out.println(TAG + ":" + volleyError.toString());*/
                System.out.println(TAG + ":" + dataObj.toString());

            }
        }) {

            /**
             * Passing some request headers
             * */
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                HashMap<String, String> headers = new HashMap<String, String>();
                headers.put("Content-Type", "application/json; charset=utf-8");
                return headers;
            }


        };
        jsonObjReq.setShouldCache(false);

        jsonObjReq.setTag("myRequest");
        // Adding request to request queue

        queue.add(jsonObjReq);



    }

public JSONObject getJsonObject(){

        JSONObject object = new JSONObject();
    try {
        if (username!=null && password !=null) {
            object.put("username", username.getText().toString());
            object.put("password", password.getText().toString());
            object.put("deviceMacAddress", "90:B6:86:0D:CE:4F");

        }
        else
        {

            Toast.makeText(this, "Email/password should not be empty", Toast.LENGTH_SHORT).show();
        }

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

return object;
}

1 个答案:

答案 0 :(得分:0)

您是数据库中已存在的数据,因此重复键尝试不同的数据或尝试发送有效且不同的所有字段。