简体   繁体   English

如何通过带有回调的通知中的URL从Picasso加载图像?

[英]How to load an image with Picasso from url inside a notification with a callback?

I would like to load an url that contains an image to a notification (using picasso library) and as callback i would like to load another image if occurs an error. 我想加载一个包含通知图像的URL(使用毕加索库),作为回调,我想在发生错误时加载另一幅图像。 I found to code for this without callback. 我发现无需回调即可对此进行编码。

Picasso.with(context).load(url).into(remoteViews, R.id.image, notificationID, notification);

If the code will not run on UI Thread.You can do like following: 如果代码无法在UI Thread上运行。您可以执行以下操作:

Bitmap bitmap = Picasso.with(context).load(url).get();
ImageView imageView = (ImageView) remoteViews.findById(R.id.image);
imageView.setImageBitmap(bitmap);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM