0

The condition response.equalsIgnoreCase("success") becomes always false, thought log.d print response = "success". Also how come printed response from system.out.print line is always empty. The goal is to receive the response from the request and satisfy the condition.

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

}

Dimitri
  • 1,924
  • 9
  • 43
  • 65
  • http://stackoverflow.com/questions/2220547/why-doesnt-system-out-println-work-in-android – Pedro Oliveira Oct 16 '14 at 08:20
  • get your point but response.equalsIgnoreCase("success") becomes always false, thought log.d print response = "success" – Dimitri Oct 16 '14 at 08:23
  • Your comment has nothing do to what you questioned. Please update your question with your problem. – Pedro Oliveira Oct 16 '14 at 08:26
  • Don't use `System.out.println`. Use `Log` only. If you use Log what is the result? – Pedro Oliveira Oct 16 '14 at 08:37
  • result is either success or failure with log.d, However i want to get the string from response but it is always null. Thought i do String my_response = response.toString(); it is not assigned – Dimitri Oct 16 '14 at 08:52
  • If `response` is always null then you have a problem elsewhere. – Pedro Oliveira Oct 16 '14 at 08:59
  • the webservice is receiving the values successfully and Log.d prints failure/success i do not think it is a webservice problem but volley library is it possible – Dimitri Oct 16 '14 at 09:06
  • I don't even see any Log.d in this code. – Pedro Oliveira Oct 16 '14 at 09:07
  • i remove it when revert back Log.d("TAG",response); – Dimitri Oct 16 '14 at 09:17
  • I'm sorry but I don't understand what you're trying to explain. – Pedro Oliveira Oct 16 '14 at 09:18
  • i am retrieving the "response" value which is a string that is either success or failure based on webservice response but i am not getting the value – Dimitri Oct 16 '14 at 09:22
  • first check whether the service return any response or not...u can use Advance REST client app for chrome...and then check in android... – Angad Tiwari Oct 21 '14 at 10:13
  • you are contradicting "the condition response.equalsIgnoreCase("success") becomes always false, thought log.d print response = "success". Also how come printed response from system.out.print line is always empty." ... how this is possible? – Angad Tiwari Oct 21 '14 at 10:14

0 Answers0