Picasso可以正常加载HTTPS URL的图片,例如:
但是,如果我使用自己的URL,如
这是我加载图片的方式:
https://i.ytimg.com/vi/28uUsJ72a1A/hqdefault.jpg
。由于YouTube将所有流量都通过 HTTPS 进行转发,因此这个也可以工作:http://i.ytimg.com/vi/28uUsJ72a1A/hqdefault.jpg
。但是,如果我使用自己的URL,如
http://www.example.com/images/djnsdfndsf.jpg
,它会将链接重定向到站点的HTTPS版本,并且只会在加载图片的时候出现错误。这是我加载图片的方式:
Picasso.with(this).load(current.getImageURL()).into(ImageView);
。请注意不要删除HTML标记。So I tried using this:
//Below code for Picasso initializing once for the app
private Picasso picasso;
private OkHttpClient okHttpClient;
okHttpClient = new OkHttpClient();
picasso = new Picasso.Builder(this)
.downloader(new OkHttpDownloader(okHttpClient))
.build();
//Below code to retrieve the images whereever required on the app
picasso.with(this).load(current.getImageURL()).into(imageView)
但是以上代码会提示无法解析OkHttpDownloader
目前我正在使用compile 'com.squareup.picasso:picasso:2.5.2'
编辑 如何强制Picasso使用http而不是https下载它?