startForeground() does not show my Notification

Solution 1:

I just noticed that startForeground() doesn't show the notification icon if the id parameter is set to 0...

startForeground(0, notification); // Doesn't work...

startForeground(1, notification); // Works!!!

I hope that it could help someone stuck on this.

Solution 2:

in addition to the best answer. you should also check that have you called setSmallIcon. On my android phone, I cannot get what I expected without calling setSmallIcon

Solution 3:

Is your service a started service or a bound service? I had the same issue with a bound service, but starting the service before binding it allowed me to call startForeground(int, notification) with and have the notification show up.