public void makeStringReqToken(String url, final HashMap<String, String> params, VolleyCallback volleyCallback) {
showDialog();
this.mparams = params;
Log.d("TAG", "PARAM " + mparams);
this.mcallback = volleyCallback;
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.POST,
url, new JSONObject(mparams),
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
dismissDialog();
s = response.toString();
mcallback.onSuccess(s);
Log.d("TAG", "Response " + s);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
dismissDialog();
mcallback.onFailure(error.toString());
}
}) {
/**
* Passing some request headers
* */
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "Basic ZGhhdmFsLnNAbXNwLWdyb3VwLmNvLnVrOjd0emhYWEN4Rit3PQ==");
return headers;
}
};
jsonObjReq.setRetryPolicy(new DefaultRetryPolicy(10000, 1, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
// Adding request to request queue
AppController.getInstance().addToRequestQueue(jsonObjReq,
"string_req");
}
showDialog();
this.mparams = params;
Log.d("TAG", "PARAM " + mparams);
this.mcallback = volleyCallback;
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.POST,
url, new JSONObject(mparams),
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
dismissDialog();
s = response.toString();
mcallback.onSuccess(s);
Log.d("TAG", "Response " + s);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
dismissDialog();
mcallback.onFailure(error.toString());
}
}) {
/**
* Passing some request headers
* */
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "Basic ZGhhdmFsLnNAbXNwLWdyb3VwLmNvLnVrOjd0emhYWEN4Rit3PQ==");
return headers;
}
};
jsonObjReq.setRetryPolicy(new DefaultRetryPolicy(10000, 1, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
// Adding request to request queue
AppController.getInstance().addToRequestQueue(jsonObjReq,
"string_req");
}