На устройствах Redme с ОС Nougat панель уведомлений позволяет отображать только одно действие при добавлении нескольких действий
Вот код, и он показывает только последнее действие вместо обоих действий. Это только Redme специфично при использовании с Nougat OS. Согласно спецификации, панель действий может отображать до трех действий, но здесь она позволяет только одно действие, которое является последним действием. Кажется, последнее действие перезаписывает предыдущие действия.
Notification notification;
Intent mIntent = new Intent(this, MainActivity.class);
pendingIntent = PendingIntent.getActivity(context, intentRequestCode, mIntent,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT);
Intent tookItIntent = new Intent(this, NotificationExpireService.class);
tookItIntent.putExtra("TASK_ID", ControlMedicationTask.TASK_ID);
tookItIntent.putExtra("NOTIFICATION_TAG", notificationTag);
tookItIntent.putExtra("NOTIFICATION_ID", notificationId);
tookItIntent.putExtra("INTENT_REQUEST_CODE", intentRequestCode);
tookItIntent.putExtra("TASK_DTO", taskDtoJson);
tookItIntent.putExtra("CONSUME_TASK", true);
PendingIntent pendingTookItIntent = PendingIntent.getService(this, intentRequestCode, tookItIntent,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT);
Intent snoozeIntent = new Intent(this, SnoozeButtonListener.class);
snoozeIntent.putExtra("TASK_ID", ControlMedicationTask.TASK_ID);
snoozeIntent.putExtra("NOTIFICATION_TAG", notificationTag);
snoozeIntent.putExtra("NOTIFICATION_ID", notificationId);
snoozeIntent.putExtra("INTENT_REQUEST_CODE", intentRequestCode);
snoozeIntent.putExtra("TASK_DTO", taskDtoJson);
PendingIntent pendingSnoozeIntent = PendingIntent.getBroadcast(this, intentRequestCode, snoozeIntent,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT);
Resources res = this.getResources();
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
builder.setContent(contentView).setColor(ContextCompat.getColor(context, R.color.azure))
//.setLargeIcon(BitmapFactory.decodeResource(res, R.drawable.breathe_logo))
.setTicker(taskDto.getDescription()).setAutoCancel(true).setPriority(8).setSound(soundUri)
.setContentTitle(res.getString(R.string.take) + " " + taskDto.getDescription())
//.setContentText(taskDto.getSubText())
.addAction(R.drawable.ic_alarm, res.getString(R.string.snooze), pendingSnoozeIntent)
.addAction(R.drawable.ic_took_it, res.getString(R.string.iTookIt), pendingTookItIntent)
//bug BREATHE-865 fix: reminder has 2 lines: 1st for Medication details, 2nd for the date. Wrapped with BigTextStyle
.setStyle(new android.support.v4.app.NotificationCompat.BigTextStyle().bigText(taskDto.getSubText()
+ '\n' + Utility.getLocalFormattedDate(taskDto.getExecutionTime(), "EEEE d MMMM")));
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
builder.setLargeIcon(getNougatLargeNotificationIcon());
builder.setSmallIcon(getNougatSmallNotificationIcon());
builder.setPriority(Notification.PRIORITY_MAX);
} else {
builder.setSmallIcon(getNotificationIcon());
}
notification = builder.build();
notification.flags |= Notification.FLAG_AUTO_CANCEL | Notification.FLAG_SHOW_LIGHTS;
notification.defaults |= Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE;
notification.ledARGB = 0xFFFFA500;
notification.ledOnMS = 800;
notification.ledOffMS = 1000;
notificationManager.notify(taskDto.getNotificationTag(), taskDto.getNotificationId(), notification);
Log.i("notify", "Notification sent.");