'How can I clear notification?

I have to hide a notification when a timer is cancelling. I instantiate a notification manager and use

myNotificationManager.cancelAll();

but it doesn't work.

What do I need to do?



Solution 1:[1]

I just solved my problem. I added a stopForeground(true);. The parameter is a boolean which determine if the notification of the foreground service will be cleared when the service is stopped. My code contained startForeground method but there is not a stopForeground method. That's why adding it was logical for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lilian Sananikone