Created
October 30, 2015 10:08
-
-
Save ar-android/b404a052df1ff85b5155 to your computer and use it in GitHub Desktop.
http header Volley
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
| public void requestWithSomeHttpHeaders() { | |
| RequestQueue queue = Volley.newRequestQueue(getActivity()); | |
| String url = "http://mimfoundation.or.id/underground/api/api.php?donat=getDetailSantri&uid=zainal"; | |
| StringRequest postRequest = new StringRequest(Request.Method.GET, url, | |
| new Response.Listener<String>() | |
| { | |
| @Override | |
| public void onResponse(String response) { | |
| // response | |
| Log.d("Response", response); | |
| Toast.makeText(getActivity(), response.toString(), Toast.LENGTH_SHORT).show(); | |
| } | |
| }, | |
| new Response.ErrorListener() | |
| { | |
| @Override | |
| public void onErrorResponse(VolleyError error) { | |
| // TODO Auto-generated method stub | |
| Log.d("ERROR", "error => " + error.toString()); | |
| } | |
| } | |
| ) { | |
| @Override | |
| public Map<String, String> getHeaders() throws AuthFailureError { | |
| Map<String, String> params = new HashMap<String, String>(); | |
| params.put("key", "qweasd321"); | |
| return params; | |
| } | |
| }; | |
| queue.add(postRequest); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment