I've find out how to set a Basic Authentication header into an ImageLoader. I was misunderstanding the answer on that link same topic. So credit goes to the real answerer.
Anyway the trick was to add an HurlStack into the getRequestQueue method as follows:
public RequestQueue getRequestQueue()
{
if (mRequestQueue == null) {
HurlStack stack = new HurlStack() {
@Override
public HttpResponse performRequest(Request<?> request, Map<String, String> headers)
throws IOException, AuthFailureError {
String auth = "Basic " + Base64.encodeToString((GlobalVariables.getInstance().getWS_KEY()+":").getBytes(),
Base64.NO_WRAP);
headers.put("Authorization", auth);
return super.performRequest(request, headers);
}
};
mRequestQueue = Volley.newRequestQueue(getApplicationContext(),stack);
}
return mRequestQueue;
}
The RequestQueue object is placed into a Global class and a singleton pattern is applied, so it means that whenever you request the RequestQueue, the authorization header will be in it. Hope it helps !