如何将Glide用于NotificationCompat.Builder setLargeIcon(Bitmap icon)
?我已经调查了tutorial,但我不想使用RemoteViews
。我还希望在不使用策略Glide.placeholder(int resource)
Glide.error(int resource)
和Glide.into(new SimpleTarget<Bitmap>(){ ... });
答案 0 :(得分:0)
这是我使用Glide 4.8.0进行的操作
val notificationBuilder = NotificationCompat.Builder(this, channelId)
.setSmallIcon(R.drawable.ic_message)
.setContentTitle("title")
.setContentText("text")
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val futureTarget = Glide.with(this)
.asBitmap()
.load(photoUrl)
.submit()
val bitmap = futureTarget.get()
notificationBuilder.setLargeIcon(bitmap)
Glide.with(this).clear(futureTarget)
notificationManager.notify(0, notificationBuilder.build())
结果: