android - 如何在android 4.1通知中使用bigTextStyle?

标签 android android-notifications

我尝试了很多方法来获取长文本样式的通知,但无法达到我的目标,请有人帮忙。

我想使用 bigTextStyle 以便在我的通知中获取多行消息。这是我的代码:

mNotificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
        PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, new Intent(ctx, MainActivity.class), 0);


        Notification noti = new Notification.Builder(ctx)
        .setContentTitle("Title")
        .setSmallIcon(R.drawable.ic_launcher)
        .setStyle(new Notification.BigTextStyle().bigText(ctx.getResources().getString(R.string.loremIpsum)))
        .setContentText(ctx.getResources().getString(R.string.loremIpsum))
        .setContentIntent(contentIntent).build();





        mNotificationManager.notify(NOTIFICATION_ID, noti);

我使用的是Android 4.1.2,所以op版本没问题。每条通知都是一条简单的单行消息,我看不到全文。请帮助我。

编辑:

好吧,我收到了长文本,但我的通知没有自动扩展,我必须用两根手指向下滑动。我如何通过代码扩展它..!?

最佳答案

您必须展开通知才能看到大文本 - 默认情况下只有顶部通知会自动展开,如 Notifications guide 中所述。 .

关于android - 如何在android 4.1通知中使用bigTextStyle?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17604859/

相关文章:

android - 防止选项菜单关闭 OptionItemSelected

android - Onesignal 不发送所有 Android 通知

android - 如何查找 whatsapp 的通知 ID

java - 带进度条的通知无法展开(Nougat+)

java - 在标记中显示信息

android - 使 gradle 脚本全局化,以便它可以在所有模块中使用

android - 当应用程序被杀死时,Firebase 通知不会在某些手机上运行

android - whatsapp/telegram 如何确保来电通知?

android - YouTube网址(适用于Android videoview)

android - 如何根据 mockk 中传递的参数从同一函数返回两个不同的模拟?