我已在通知构建器中使用 addaction 在通知中添加了操作,当通知在平视模式下进行通知时,我需要隐藏操作按钮,并且仅在通知展开时才显示操作按钮
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(getNotificationIcon())
.setContentTitle("Sample App")
.setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND)
.setPriority(Notification.PRIORITY_MAX)
.setLights(Color.BLUE, 3000, 3000)
.setAutoCancel(true)
.setAction(action1)
.setAction(action2)
.setContentText(body);