我创建了一个通知
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();
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句