Calling a method on android button click

I am trying to make a web service call via android button click. I’ve managed to rectify the errors, but it shows some bugs on getting response. I receive null response. Below is my code. Could someone debug me please..!

My code:

refresh_btn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            HttpHandler httpHandler1 = new HttpHandler();
            String res = null;
            String authToken = "MlSyULrWlFgVk28";

            try {

                Log.d("edwLog", TAG + " get_payment_notifications " + HttpHandler.API_URL + "get_payment_notifications/" + authToken + "/");
                res = httpHandler1.makeServiceCall(HttpHandler.API_URL + "get_payment_notifications/" + authToken + "/", HttpHandler.GET);
                Log.d("edwLog", TAG + " response > " + res);
                if (res != null) {
                    JSONObject jsonObject = new JSONObject(res);
                    String responseType = jsonObject.getString("type");
                    if (responseType.equals("success")) {
                        if (jsonObject.has("response")) {

                            JSONArray jsonArray = jsonObject.getJSONArray("response");
                            for (int i = 0; i < jsonArray.length(); i++) {
                                notifications.add(jsonArray.getJSONObject(i));
                            }
                        }
                    }
                }

            } catch (Exception e) {
                e.printStackTrace();
                Log.d("edwLog", TAG + " IOException > " + e.toString());
            }
        }
    });

Answer

Found the bug..! The mistake was, I had passed the AuthToken as a default String. Now I declared it as “null” in final, i.e., before onCreate and deleted it from inside the ClickEvent. And its done.. The right code below..

refresh_btn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            HttpHandler httpHandler1 = new HttpHandler();
            String res = null;


            try {

                Log.d("edwLog", TAG + " get_payment_notifications " + HttpHandler.API_URL + "get_payment_notifications/" + AuthToken + "/");
                res = httpHandler1.makeServiceCall(HttpHandler.API_URL + "get_payment_notifications/" + AuthToken + "/", HttpHandler.GET);
                Log.d("edwLog", TAG + " response > " + res);
                if (res != null) {
                    JSONObject jsonObject = new JSONObject(res);
                    String responseType = jsonObject.getString("type");
                    if (responseType.equals("success")) {
                        if (jsonObject.has("response")) {

                            JSONArray jsonArray = jsonObject.getJSONArray("response");
                            for (int i = 0; i < jsonArray.length(); i++) {
                                notifications.add(jsonArray.getJSONObject(i));
                            }
                        }
                    }
                }

            } catch (Exception e) {
                e.printStackTrace();
                Log.d("edwLog", TAG + " IOException > " + e.toString());
            }
        }
    });