我希望通知不会在几秒钟后消失。所以我创建了这样的通知:
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setSmallIcon(R.drawable.cast_ic_notification_small_icon)
.setDefaults(Notification.FLAG_ONGOING_EVENT)
.setPriority(Notification.PRIORITY_HIGH)
.setContentTitle(notificationDetails.getSubject())
.setContentText(notificationDetails.getMessage())
.setColor(context.getResources().getColor(R.color.colorPrimary))
.setOngoing(true);
Run Code Online (Sandbox Code Playgroud)
并设置 FLAG_ONGOING_EVENT 和方法 setOngoing(true)。
但几秒钟后,通知继续消失。我希望通知仅在用户单击时消失。谢谢你。