我得到一个图像的URL与密码保护。我知道如何做与认证,但我想这样做与毕加索。 任何人都可以告诉我,如何将密码保护的图像加载到带有毕加索图像加载程序库的imageview。用picasso加载密码保护的图像到imageview图像加载器库在android
下面是代码做身份验证:
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;
}
你如何做与认证?你能告诉我们吗?你如何将密码传递给url? – SripadRaj