gpt4 book ai didi

Android - 如何在通知中显示大文本

转载 作者:搜寻专家 更新时间:2023-11-01 08:50:37 27 4
gpt4 key购买 nike

我需要实现一个代码来在通知中显示 200 个字符的大文本。我在这里使用了以下代码,但它显示单行。

       Intent notificationIntent;
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.icon)
.setContentTitle(context.getString(R.string.app_name))
.setContentText(message)
.setDefaults(Notification.DEFAULT_ALL)
.setAutoCancel(true);
notificationIntent = new Intent(context, Main.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pintent = PendingIntent.getActivity(context, 0,
notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(pintent);
NotificationManager mNotifyMgr =
(NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
// Builds the notification and issues it.
mNotifyMgr.notify(1, mBuilder.build());

最佳答案

您可以选择不同的样式用于通知生成器:

在您的情况下,我会使用 NotificationCompat.BigTextStyle。可以找到更多详细信息here.

使用时不要忘记导入 v4 支持。

关于Android - 如何在通知中显示大文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23799669/

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