private void CheckAddon(String bodyParams, final String type) {
final String requestBody = bodyParams;
String url = "";
StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
@Override
public void onResponse(String result) {
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Log.e("Volley Error", volleyError.toString());
Toast.makeText(context.getApplicationContext(), R.string.apiErrorMsg, Toast.LENGTH_LONG).show();
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
headers.put("Client-Service", Constants.clientService);
headers.put("Auth-Key", Constants.authKey);
headers.put("Content-Type", Constants.contentType);
headers.put("User-ID", Utility.getSharedPreferences(context.getApplicationContext(), "userId"));
headers.put("Authorization", Utility.getSharedPreferences(context.getApplicationContext(), "accessToken"));
return headers;
}
@Override
public String getBodyContentType() {
return "application/json; charset=utf-8";
}
@Override
public byte[] getBody() throws AuthFailureError {
try {
return requestBody == null ? null : requestBody.getBytes("utf-8");
} catch (UnsupportedEncodingException uee) {
VolleyLog.wtf("Unsupported Encoding while trying to get the bytes of %s using %s", requestBody, "utf-8");
return null;
}
}
};
//Creating a Request Queue
RequestQueue requestQueue = Volley.newRequestQueue(context.getApplicationContext());
//Adding request to the queue
requestQueue.add(stringRequest);
}