我尝试了很多方法来获取长文本样式的通知,但无法达到我的目标,请有人帮忙。
我想使用 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/