(Notifications) Does anyone know what the behavior would be if a foreground service is showing a notification, and is then stopped after N time - but its notification is updated shortly after the stop call?
- Would it dismiss the notification (as expected)?
- Or, would the notification be updated, and stick around even though the service is destroyed?
😶 2
r
Remy Benza
04/27/2022, 8:07 PM
NotificationManager will immediately remove the notification attached to a foreground service when the service is destroyed
z
Zoltan Demant
04/29/2022, 4:06 AM
Thanks for the reply @Remy Benza. Thats the way I understood it to work as well, I cant 100% verify this but I feel like thats not always the case though (this happens 1/1000 of the time, approximately).
If
notificationManager.notify
is invoked at just the wrong time, e.g. close to when the service is being destroyed, I suspect that a new notification is produced which sticks around even after the service is destroyed. Even using
notificationManager.cancel
in the services onDestroy doesnt cancel out this behavior. Since its so rare, I cant really verify this theory until enough people have used the workaround though, so I guess time will tell.