在通知按钮下方显示文字

Show text below notification button

在上图中,我很确定通知样式是 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());

您可以使用 setContentTextsetSubText 查看问题。

未读消息数: 希望 this 有帮助