Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
Version used:2.10.0-beta01
Devices/Android versions reproduced on: SDK35
If this is a bug in the library, we would appreciate if you could attach:
- Sample project to trigger the issue.
- A screenrecord or screenshots showing the issue (if UI related).
I have a Worker class which start and download some data. And according to documentation "If your app's dataSync foreground services have run for 6 hours in the last 24, you cannot start another dataSync foreground service unless the user has brought your app to the foreground (which resets the timer). If you try to start another dataSync foreground service, the system throws ForegroundServiceStartNotAllowedException with an error message like "Time limit already exhausted for foreground service type dataSync".
But i have multiple try-catch blocks in my worker class, exactly for `setForeground(getForegroundInfo())`. Do you have any recommendation to fix this problem?
Full stacktrace:
java.lang.RuntimeException: Unable to start service androidx.work.impl.foreground.SystemForegroundService@42c61d0 with Intent { act=ACTION_START_FOREGROUND cmp=com.example.project/androidx.work.impl.foreground.SystemForegroundService (has extras) }: android.app.ForegroundServiceStartNotAllowedException: Time limit already exhausted for foreground service type dataSync
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5782)
at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(ActivityThread.java:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2888)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loopOnce(Looper.java:250)
at android.os.Looper.loop(Looper.java:340)
at android.app.ActivityThread.main(ActivityThread.java:9774)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:621)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957)
Caused by: android.app.ForegroundServiceStartNotAllowedException: Time limit already exhausted for foreground service type dataSync
at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
at android.os.Parcel.readParcelableInternal(Parcel.java:5089)
at android.os.Parcel.readParcelable(Parcel.java:5071)
at android.os.Parcel.createExceptionOrNull(Parcel.java:3251)
at android.os.Parcel.createException(Parcel.java:3240)
at android.os.Parcel.readException(Parcel.java:3223)
at android.os.Parcel.readException(Parcel.java:3165)
at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7677)
at android.app.Service.startForeground(Service.java:863)
at androidx.work.impl.foreground.SystemForegroundService$Api31Impl.a(SystemForegroundService.java:4)
at androidx.work.impl.foreground.SystemForegroundService.startForeground(SystemForegroundService.java:0)
at androidx.work.impl.foreground.SystemForegroundDispatcher.handleNotify(SystemForegroundDispatcher.java:0)
at androidx.work.impl.foreground.SystemForegroundDispatcher.onStartCommand(SystemForegroundDispatcher.java:0)
at androidx.work.impl.foreground.SystemForegroundService.onStartCommand(SystemForegroundService.java:0)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5764)