Created
June 24, 2020 19:09
-
-
Save paulonteri/b5104b5ee0ad2cfa15367ffe24159e04 to your computer and use it in GitHub Desktop.
Android Volley - Making Post request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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