在上图中,我非常确定通知样式为Notification.MessageStyle
该代码在我的代码中正常工作,但是我无法在其下方设置文本,该文本中的一个显示图像中的电子邮件,另一个文本显示未读邮件的数量。如何在此处显示两个文本视图?
我的代码:
Person user = new Person.Builder().setIcon(IconCompat.createWithBitmap(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher))).setName("You").build();
NotificationCompat.MessagingStyle style = new NotificationCompat.MessagingStyle(user)
.setConversationTitle("Title")
.addMessage("hi", System.currentTimeMillis(), new Person.Builder().setName("Pemba").build())
.addMessage("hello", System.currentTimeMillis(), new Person.Builder().setName("Suku").build())
.addMessage("hello", System.currentTimeMillis(), new Person.Builder().build())
.setGroupConversation(true);
Intent intent = new Intent(context, MainActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(context, (int) System.currentTimeMillis(), intent, 0);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
new Intent(context, MainActivity.class), 0);
final NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context, CHANNNEL_ID);
mBuilder.setSmallIcon(R.drawable.robot_noti)
.setColor(context.getResources().getColor(R.color.colorPrimary))
.addAction(android.R.drawable.radiobutton_on_background, "Button", pIntent)
.setStyle(style)
.setContentIntent(contentIntent)
.setDefaults(Notification.DEFAULT_SOUND)
.setOnlyAlertOnce(true)
.setAutoCancel(true);
final NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, mBuilder.build());