Thursday, 16 March 2017

Android Volley

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

                    @Override                    public void onResponse(JSONObject response) {
                        Log.d(TAG, response.toString());
                        listener.notifyResponse(response.toString(), 200);

                    }
                }, new Response.ErrorListener() {

            @Override            public void onErrorResponse(VolleyError error) {
                VolleyLog.d(TAG, "Error: " + error.getMessage());

            }
        }) {

            /**             * 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");
                headers.put("apiKey", "xxxxxxxxxxxxxxx");
                headers.put("Cookie", sam);
                return headers;
            }

        };

// Adding request to request queue        App.getInstance().addToRequestQueue(jsonObjReq);


    }


UseFul Links



No comments:

Post a Comment

Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...