1

我正在尝试从NotificationCompat.MessagingStyle.Message.setData()方法中的远程 url 加载图像。

代码是这样的

val senderImg = Picasso.with(this).load(senderAvatar).get()

val sndr = Person.Builder()
                .setName(senderName)
                .setIcon(IconCompat.createWithBitmap(senderImg))
                .build()

bldr = NotificationCompat.Builder(this, id)
                    .setSmallIcon(R.drawable.ic_notification)
                    .setContentIntent(pendingIntent)
                    .setPriority(NotificationManager.IMPORTANCE_DEFAULT)
                    .setSmallIcon(R.drawable.ic_notification)
                    .setContentTitle(title)
                    .setAutoCancel(true)

val imageUri = Uri.parse(imageUrl)

mssg = NotificationCompat.MessagingStyle.Message(
                    msg,
                    Date().time, sndr
                ).setData("image/", "https://i.imgur.com/wrv4Ngp.jpg")



NotificationCompat.MessagingStyle(sndr)
                .addMessage(mssg)
                .setBuilder(bldr)


NotificationManagerCompat.from(this).notify(NOTIFICATION_ID, bldr.build())

但是图像没有显示。任何帮助,将不胜感激。谢谢

4

0 回答 0