Skip to content

Instantly share code, notes, and snippets.

@ar-android
Created October 30, 2015 10:08
Show Gist options
  • Select an option

  • Save ar-android/b404a052df1ff85b5155 to your computer and use it in GitHub Desktop.

Select an option

Save ar-android/b404a052df1ff85b5155 to your computer and use it in GitHub Desktop.
http header Volley
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