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....
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("name", "name");
params.put("email", "[email protected]");
params.put("pass", "password");
return params;
}
JSONObject obj = new JSONObject();
obj.put("isboolean",false)
JsonObjectRequest req = new JsonObjectRequest(Constants.URL_PATH, obj,
new Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
}, new ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
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<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
parseDirectionsData(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
}
}){
@Override
protected Map<String, String> getParams() throws AuthFailureError {
HashMap<String, String> 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With