Created
November 1, 2016 12:01
-
-
Save ZaeemSattar/8e884473260c3b06c27d48e38155e4b3 to your computer and use it in GitHub Desktop.
Through this volley string request you can hit server for String response
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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