Just a heads up as I wasted way too many hours on this. I kept getting this exception even though I was calling startForeground(..)
as the first thing in onCreate(..)
.
In the end I found that the problem was caused by using NOTIFICATION_ID = 0
. Using any other value seems to fix this.