https://kotlinlang.org logo
#android
Title
# android
r

Remy Benza

01/23/2021, 3:50 PM
Im using an NotificationListenerService for snoozing certain notifications on condition X by calling snoozeNotification(id, duration). When condition X changes during the snooze periode, how do you 'unsnooze' such a notification?
You can query a list of all the snoozed notifications by calling the getSnoozedNotifications function. But unsure which property on the
Notification
object inside the
StatusbarNotification
object I would need to call/set. Any one a clue?
My notifications now remain snoozed until the duration is over or the phone reboots, even if condition X has changed.
f

Farhad

01/25/2021, 6:55 AM
Isn't it .cancel() ?
r

Remy Benza

01/25/2021, 8:10 AM
.cancel() on what object? doesn't seem to be one on either
Notification
or
StatusbarNotification
f

Farhad

01/25/2021, 8:14 AM
I meant Notification. Hmmm I remember that some time back i had similar issue and calling cancel on Notification object was the solution. I need to check it again
r

Remy Benza

01/25/2021, 8:15 AM
you can call
cancelNotification()
image.png
but this just cancels the notification, I want the opposite behavior, to basically 'uncancel' the snooze periode
wait, maybe when I set the snooze duration to 0?
nice, this works 🙂
2021-01-25_09h24_48.png
just call
snoozeNotification()
with duration 0, and your notification becomes visible again.
@Farhad could you check your code? It's still inconsistent when I call
snoozeNotification(0)
2 Views