Skip to content

Instantly share code, notes, and snippets.

@paulonteri
Created June 24, 2020 19:09
Show Gist options
  • Save paulonteri/b5104b5ee0ad2cfa15367ffe24159e04 to your computer and use it in GitHub Desktop.
Save paulonteri/b5104b5ee0ad2cfa15367ffe24159e04 to your computer and use it in GitHub Desktop.
Android Volley - Making Post request
// Tag used to cancel the request
String tag_json_object = "json_obj_request";
String url = "http://velmm.com/apis/volley_array.json";
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Method.POST,
url, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.d(TAG, response.toString());
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d(TAG, error.toString());
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("name", "Velmm.com");
params.put("password", "*******");
return params;
}
};
// Adding request to request queue
AppController.getInstance().addToRequestQueue(jsonObjectRequest, tag_json_object);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment