Volley api is powerful api to perform network operation like to perform long running network operations.
you have to create HashMap that will contain key value pair for each variable and then put that hashmap object in JsonObjectRequest as a parameter.
HashMap<String, String> params = new HashMap<String, String>();
params.put("key3", "value");
params.put("key4", "value");
JsonObjectRequest req = new JsonObjectRequest(URL, new JSONObject(params),
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.e("Response:%n %s", response.toString());
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("Error: ", error.getMessage());
}
});
0 Comment(s)