gpt4 book ai didi

android - 如何添加 Android Notification 附加说明?

转载 作者:行者123 更新时间:2023-11-29 17:51:22 26 4
gpt4 key购买 nike

我尝试了一个通知示例。

如何添加像这张图片这样的附加说明

enter image description here

我的通知码

NotificationCompat.Builder  mBuilder = new NotificationCompat.Builder(this)
.setContentTitle("New Message with implicit intent")
.setContentText("New message from javacodegeeks received...")
.setTicker("Implicit: New Message Received!")
.setSmallIcon(MainActivity.NotiImage)
.setAutoCancel( false )
.setNumber( ++NotificationHelper.messagges )
.setLargeIcon(BitmapFactory.decodeResource( getResources(), MainActivity.NotiImage ));

NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();

String[] events = new String[3];
events[0] = new String("1) Message for implicit intent");
events[1] = new String("2) big view Notification");
events[2] = new String("3) from javacodegeeks!");

inboxStyle.setBigContentTitle("More Details:");
for (int i=0; i < 9; i++) {
inboxStyle.addLine("olkun " + i);
}
mBuilder.setStyle(inboxStyle);
NotificationManager myNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
myNotificationManager.notify(1, mBuilder.build());

最佳答案

您想使用 NotificationCompat.InboxStyle.setSummaryText() :

inboxStyle.setSummaryText("Summary Text goes here");

developer guide 中也有描述作为:

Summary text

Allows you to add a line of text below the details area.

关于android - 如何添加 Android Notification 附加说明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22617084/

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