Volley is a library that makes networking for Android apps easier and most importantly, faster. It manages the processing and caching of network requests and it saves developers valuable time from writing the same network call/cache code again and again.
/*.....Add this dependencies into gradle file.....*/
compile 'com.android.volley:volley:1.1.0'
/*.....Sending a simple request.....*/
RequestQueue requestQueue = Volley.newRequestQueue(Login.this);
StringRequest stringRequest = new StringRequest(Request.Method.POST, "url......",
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String,String> params = new HashMap<String, String>();
params.put("key1","mnbm");
return params;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String,String> Header = new HashMap<String, String>();
Header.put("token","Mhbhbjh67bhBj53");
return Header;
}
};
requestQueue.add(stringRequest);
/*.....Add this dependencies into gradle file.....*/
compile 'com.android.volley:volley:1.1.0'
/*.....Sending a simple request.....*/
RequestQueue requestQueue = Volley.newRequestQueue(Login.this);
StringRequest stringRequest = new StringRequest(Request.Method.POST, "url......",
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String,String> params = new HashMap<String, String>();
params.put("key1","mnbm");
return params;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String,String> Header = new HashMap<String, String>();
Header.put("token","Mhbhbjh67bhBj53");
return Header;
}
};
requestQueue.add(stringRequest);
Comments
Post a Comment