Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to send json data to server in android using volley

  RequestQueue queue = Volley.newRequestQueue(this);

  private void makeJsonObjReq() {
    showProgressDialog();


            Map<String, String> postParam= new HashMap<String, String>();
            postParam.put("un", "xyz@gmail.com");
            postParam.put("p", "somepasswordhere");


    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Method.POST,
            Const.URL_LOGIN, new JSONObject(postParam),
            new Response.Listener<JSONObject>() {

                @Override
                public void onResponse(JSONObject response) {
                    Log.d(TAG, response.toString());
                    msgResponse.setText(response.toString());
                    hideProgressDialog();
                }
            }, new Response.ErrorListener() {

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

        /**
         * 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.setTag(TAG);
    // Adding request to request queue
    queue.add(jsonObjReq);

    // Cancelling request
    /* if (queue!= null) {
    queue.cancelAll(TAG);
    } */

}
Comment

PREVIOUS NEXT
Code Example
Javascript :: Node.js passing parameters to client via express render 
Javascript :: spherical.computeheading javascript 
Javascript :: different db connectons depending on env in typeorm 
Javascript :: Load Balance 4 instances of api.js node js 
Javascript :: save in local storage with expiration 
Javascript :: javascript accessing this in callback 
Javascript :: button prssed value show in text javascript 
Javascript :: 4.8. Input with readline-sync¶ 
Javascript :: Checking equality with Promise.resolve vs async return 
Javascript :: _this.errors.push(error.response.data.error); 
Javascript :: clean facebook graphql response 
Javascript :: 1update normalize-url 
Javascript :: v4 history for react action or api calls 
Javascript :: 9.4.1.2. Loop Condition¶ 
Javascript :: midpointrounding.awayfromzero javascript 
Javascript :: log errors react 
Javascript :: how to replace all words in javascript in hindi 
Javascript :: kjk 
Javascript :: javascript iframe listener 
Javascript :: js check if tab switched 
Javascript :: alegato termino excluido 
Javascript :: Destructing variable assignment 
Javascript :: how to get the number of days in a month in javascript 
Javascript :: how to print date in javascript without time 
Javascript :: how to show numbers in javascript using while loop 
Javascript :: why is javascript the worst programming language 
Javascript :: replace function javascript recurrent 
Javascript :: react history push search params 
Javascript :: Jasonplaseholder 
Javascript :: random number from 1 to 10000 js 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =