i am getting an image url which is protected with password.I know how to do it with the Authenticator but i want to do this with Picasso. Can anyone please tell me that how to load password protected images to a imageview with Picasso Image loader Library.
Below is the code to do with Authenticator:
private Bitmap download_Image(String url) {
Bitmap bmp = null;
try {
URL ulrn = new URL(url);
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(imagePassword, "mypass".toCharArray());
}
});
HttpURLConnection con = (HttpURLConnection) ulrn.openConnection();
InputStream is = con.getInputStream();
bmp = BitmapFactory.decodeStream(is);
if (null != bmp)
return bmp;
} catch (Exception e) {
e.printStackTrace();
}
return bmp;
}