对于使用 notificationBuilder 创建的 android 通知,未在通知托盘中获取取消选项
Not getting cancel option in notification tray for android notification created using notificationBuilder
这是我用来创建通知的代码。
notificationBuilder.setOngoing(true)
.setSmallIcon(R.drawable.notifications_icon)
.setContentTitle("Upload")
.setContentText("image is being uploaded")
.setProgress(0, 0, true).setAutoCancel(true).build();
我能正常收到通知,但无法清除。
这是因为你写道:
setOngoing(true)
这意味着您希望通知保留。 解决方案? 删除此行(或将其设置为 false
),它将被忽略。
这是我用来创建通知的代码。
notificationBuilder.setOngoing(true)
.setSmallIcon(R.drawable.notifications_icon)
.setContentTitle("Upload")
.setContentText("image is being uploaded")
.setProgress(0, 0, true).setAutoCancel(true).build();
我能正常收到通知,但无法清除。
这是因为你写道:
setOngoing(true)
这意味着您希望通知保留。 解决方案? 删除此行(或将其设置为 false
),它将被忽略。