带有展开通知的NotificationCompat.Builder无效

时间:2016-11-26 09:59:35

标签: android android-notifications

我正在尝试通过以下代码扩展通知,如果文本很长。

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(getNotificationIcon())
                .setColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary))
                .setContentTitle(getString(R.string.app_name))
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody))
                .setContentIntent(pendingIntent);

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

notificationManager.notify(0, notificationBuilder.build());

但它显示单行通知,无法展开。我的测试设备是棉花糖。

1 个答案:

答案 0 :(得分:0)

使用setpriority可能会有所帮助 -

.setPriority(Notification.PRIORITY_MAX)