[Android] volley library with Basic Authentication

I found HttpHeaders and HttpAuthentication Class from

Spring for Android(http://matthias.jimdo.com/2011/07/04/consuming-restful-web-services-on-android-using-spring-android/)

then I follow this ….

http://stackoverflow.com/questions/16817980/how-does-one-use-basic-authentication-with-this-library

to extend the JsonObjectRequest from volley like this…

public class feedJsonObjectRequest extends JsonObjectRequest {

public feedJsonObjectRequest(int method, String url,

JSONObject jsonRequest, Listener<JSONObject> listener,

ErrorListener errorListener) {

super(method, url, jsonRequest, listener, errorListener);

// TODO Auto-generated constructor stub

}

@Override

public Map<String, String> getHeaders() throws AuthFailureError {

// TODO Auto-generated method stub

HttpHeaders requestHeaders = new HttpHeaders();

HttpAuthentication auth = new HttpBasicAuthentication(“username", “password");

requestHeaders.setAuthorization(auth);

return requestHeaders.toSingleValueMap();

}

}

then your can use it just like the normal jsonObjectRequest()….

feedJsonObjectRequest jsObjRequest = new feedJsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {})