gpt4 book ai didi

android - 是否可以在同一通知中同时使用 InboxStyle 和 BigText

转载 作者:行者123 更新时间:2023-11-29 23:53:21 25 4
gpt4 key购买 nike

我创建了一个通知

NotificationCompat.InboxStyle

并使用

添加文本
inboxStyle.addLine

用于多条短信。但是,当我添加

Notification.BigTextStyle

在通知中,BigTextStyle 不工作,因为通知已经 setStyle

我的通知是;

Notification summaryNotification = new
NotificationCompat.Builder(this, notificationChannelId)
.setContentTitle("title")
.setStyle(addInboxStyle())
.setStyle(addBigTextStyle())
.setGroupSummary(true)
.setContentIntent(pendingIntent)
.setChannelId(notificationChannelId)
.build();

最佳答案

不,这是不可能的但是您可以使用 MessagingStyle 通知获得类似的行为,您可以在不扩展和扩展通知的情况下使用大消息,并且您还可以在通知中包含多行

https://developer.android.com/reference/android/app/Notification.MessagingStyle

NotificationCompat.MessagingStyle.Message message1 =
new NotificationCompat.MessagingStyle.Message(messages[0].getText(),
messages[0].getTime(),
messages[0].getSender());
NotificationCompat.MessagingStyle.Message message2 =
new NotificationCompat.MessagingStyle.Message(messages[1].getText(),
messages[1].getTime(),
messages[1].getSender());

Notification notification = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.drawable.new_message)
.setStyle(new NotificationCompat.MessagingStyle(resources.getString(R.string.reply_name))
.addMessage(message1)
.addMessage(message2))
.build();

关于android - 是否可以在同一通知中同时使用 InboxStyle 和 BigText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50639666/

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