We adjusted our ongoing notification for Oreo and it worked great. Now, on Pie only (not happening on Oreo devices), we\'re getting the titled error. Has something changed in
As mentioned here Background Service Limitations, the app/service has five seconds to call startForeground()
, If the app does not call startForeground() within the time limit, the system stops the service and declares the app to be ANR.
There are some possibilities:
startForeground()
method.onCreate
method will not be called, instead onStartCommand
will be called. Then move your logic to onStartCommand
to call startForeground()
method.startForeground
must not be 0, otherwise it will also cause the crash.