Skip to content

Instantly share code, notes, and snippets.

@ZaeemSattar
Created November 1, 2016 12:01
Show Gist options
  • Save ZaeemSattar/8e884473260c3b06c27d48e38155e4b3 to your computer and use it in GitHub Desktop.
Save ZaeemSattar/8e884473260c3b06c27d48e38155e4b3 to your computer and use it in GitHub Desktop.
Through this volley string request you can hit server for String response
private static final int MY_SOCKET_TIMEOUT_MS = 10000;
ProgressDialog ringProgressDialog;
ringProgressDialog = ProgressDialog.show(this, "", "please wait", true);
ringProgressDialog.setCancelable(false);
ringProgressDialog.show();
StringRequest request = new StringRequest(Request.Method.POST, End_Points.CHECK_LEAVES,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
ringProgressDialog.dismiss();
remaining_leaves.setText(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(Leave_Activity.this, error.toString(), Toast.LENGTH_SHORT).show();
ringProgressDialog.dismiss();
}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("user_id", userid);
return params;
}
};
request.setRetryPolicy(new DefaultRetryPolicy(
MY_SOCKET_TIMEOUT_MS,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
requestQueue.add(request);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment