gpt4 book ai didi

android - 如何在 NotificationCompat.Builder.setLargeIcon() 中加载 Glide 缓存图片?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:18:05 26 4
gpt4 key购买 nike

Like this image 我正在尝试将通知大图标设置为用户个人资料缩略图比如whatsapp或其他聊天应用

我试过了

 Glide.with(context)
.asBitmap()
.load(messageNotification.getLargeIcon())
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
builder.setLargeIcon(resource);

}
});

但是没用..有帮助吗?

最佳答案

如果你使用 glide 设置大图标..你还应该通知 NotificationManager onResourceReady(resource, transition)

.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap res, Transition<? super Bitmap> t) {
builder.setLargeIcon(res);
yourNotificationManager.notify(id, builder.build());

}
});

This is because glide uses background thread to load image..so before your image is loaded into builder... the notification manager is already notified (mainthread) with builder not having large image..

关于android - 如何在 NotificationCompat.Builder.setLargeIcon() 中加载 Glide 缓存图片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48967955/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com