-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Milestone
Description
Starting up the Soundscape service is resulting in an exception because the service isn't in the foreground:
Fatal Exception: java.lang.RuntimeException: Unable to start service org.scottishtecharmy.soundscape.services.SoundscapeService@432775e with null: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service org.scottishtecharmy.soundscape/.services.SoundscapeService
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5471)
at android.app.ActivityThread.-$$Nest$mhandleServiceArgs()
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2647)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loopOnce(Looper.java:248)
at android.os.Looper.loop(Looper.java:338)
at android.app.ActivityThread.main(ActivityThread.java:9067)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932)
To fix these startAsForegroundService needs to be adjusted to be similar to the MyCameraService example code in:
https://developer.android.com/develop/background-work/services/fgs/launch
However, it's not clear why the app isn't in the foreground. Need to read and fully understand https://developer.android.com/develop/background-work/services/fgs/restrictions-bg-start