我正在使用picasso库在我的应用中加载图片。它在Android版本低于5.1.1时工作正常,但在5.1.1中没有。
这是未加载的示例网址
http://sexocomcafe1-teste.tempsite.ws/imagensUsuario13/avata/Atração%20PerigosaRJ_44690132.jpg
这个网址在4.2.1和其他网站中完全加载,但在我的5.1.1设备中没有
这是我试过的代码
//Singleton instance of picasso
getPicassoInstance(){
if (picasso == null) {
picasso = new Picasso.Builder(PreferenceHelper.getContext()).executor(Executors.newSingleThreadExecutor())
.build();
}
return picasso;
}
getPicassoInstance().load(url).placeholder(R.drawable.default_image)
.into(myImageView);
Also following code by using the Target
Target targetAppLogo = new Target() {
@Override
public void onPrepareLoad(Drawable arg0) {
Logger.error("on prepare load avatar");
}
@SuppressLint("NewApi")
@Override
public void onBitmapLoaded(Bitmap bitmap, LoadedFrom arg1) {
Logger.error("Save aavatar success ");
}
@Override
public void onBitmapFailed(Drawable arg0) {
Logger.error("Bitmap loading failed ");
}
};
getPicassoInstance().load(url).into(targetAppLogo);
上面的代码为4.2.1提供了位图下载成功,并为5.1.1提供了位图加载失败。
我不知道代码出了什么问题 任何帮助表示赞赏
答案 0 :(得分:0)
使用 Html.fromHtml(String)方法。这应该可以解决您的问题。
在加载图片之前添加以下行:
=INFO REPORT==== 2015-10-11 02:02:18 ===
I(<0.9757.0>:my_module:46) : Running filter. Debug: [60,"iq",
[[32,"type",61,39,
"error",39],
[32,"id",61,39,
"purpled0f53aba",39]],
62,
[[60,"ping",
[[32,"xmlns",61,39,
"urn:xmpp:ping",39]],
47,62],
[60,"error",
[[32,"code",61,39,
"503",39],
[32,"type",61,39,
"cancel",39]],
62,
[[60,
"service-unavailable",
[[32,"xmlns",61,39,
"urn:ietf:params:xml:ns:xmpp-stanzas",
39]],
47,62]],
60,47,"error",62]],
60,47,"iq",62]
所以它看起来像:
url = Html.fromHtml(url).toString();
以下是我加载您提供的网址图片的示例代码:
url = Html.fromHtml(url).toString();
getPicassoInstance().load(url).placeholder(R.drawable.default_image)
.into(myImageView);
答案 1 :(得分:0)
Aquery也用于图像加载,下载aquery jar并将其导入项目并尝试这种方式
bundle exec guard init rspec