Volley -> JSONRequestWithParameters

————————————————————————–

RequestQueue requestQueue = Volley.newRequestQueue(this);

String url =”–“;

Map<String,String> params = new HashMap<String, String>();
params.put(“key”,”–“);
params.put(“email”,”–“);
params.put(“password”,”–“);

JsonObjectRequest jsonRequest = new JsonObjectRequest(
Request.Method.POST,
url,
new JSONObject(params),
new Response.Listener<JSONObject>(){
@Override
public void onResponse(JSONObject response) {

System.out.println(” getJSONRequestWithParameters -> Response : “+response);
}
},
new Response.ErrorListener(){
@Override
public void onErrorResponse(VolleyError error) {
System.out.println(” getJSONRequestWithParameters -> Error : “+error);
}
}
){
// this is optional if you don’t use this
@Override
public String getBodyContentType() {
return “application/json; charset=utf-8”;
}
};

jsonRequest.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 2, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

// Add the request to the RequestQueue.
requestQueue.add(jsonRequest);

————————————————————————-

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s