onResponse(字符串响应)响应值未在logcat中打印

时间:2014-10-16 08:01:10

标签: android android-volley

条件response.equalsIgnoreCase("成功")变为总是假的,以为log.d print response =" success"。另外,system.out.print行的打印响应如何始终为空。目标是从请求中接收响应并满足条件。

StringRequest postRequest = new StringRequest(Request.Method.POST,
        Constant.SUBSCRIPTION_URL, new Response.Listener<String>() {
    @Override
    public void onResponse(String response) {

        System.out.println("xxSuccess "+response);

        if (response.equalsIgnoreCase("success")) {

            SimpleDialogFragment
            .createBuilder(
                    getActivity(),
                    getActivity()
                    .getSupportFragmentManager())
                    .setTitle(R.string.app_name)
                    .setMessage(R.string.subscription_sucess)
                    .show();

        } else {

            SimpleDialogFragment
            .createBuilder(
                    getActivity(),
                    getActivity()
                    .getSupportFragmentManager())
                    .setTitle(R.string.app_name)
                    .setMessage(R.string.subscription_failure)
                    .show();
        }


    }
}, new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError error) {

        // error
        Util.volleyError(error);
    }
}) {
    @Override
    protected Map<String, String> getParams() {
        Map<String, String> params = new HashMap<String, String>();

        params.put("name", firstName + " " + name);
        params.put("email", contact_email);
        params.put("profession", profession);
        params.put("dob", dateofbirth);
        params.put("gender", gender);
        params.put("region", region);
        params.put("country", country);

        return params;

    }


};

queue.add(postRequest);

}

0 个答案:

没有答案