我得到一個圖像的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