How to post boolean or integer value using volley

前端 未结 4 1632
予麋鹿
予麋鹿 2021-01-18 21:05

I want to post boolean,double data using volley library.I am not getting how to use it.Is there any other process.Thanks in advance.

Here is my method....

         


        
4条回答
  •  感情败类
    2021-01-18 21:49

    JSONObject object = new JSONObject();
    try {
        object.put("compression", false);
        object.put("instructions", true);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    
    JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, API_URL, object, new Response.Listener() {
        @Override
        public void onResponse(JSONObject response) {
            parseDirectionsData(response);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            error.printStackTrace();
        }
    }){
        @Override
        protected Map getParams() throws AuthFailureError {
            HashMap params = new HashMap<>();
            params.put("loc", "-33.9717974,18.6029783");
            return params;
        }
    };
    

    Any of the parameters that are not Strings you can wrap them into the Json Object.

提交回复
热议问题