如何在提示通知中隐藏操作按钮

时间:2019-07-09 11:13:30

标签: android notifications

我已在通知构建器中使用 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);

0 个答案:

没有答案