Bug P3
Status Update
Comments
b1...@gmail.com <b1...@gmail.com> #2
I'm not sure how to edit the description. But forgot to add that this will work when the app is in the foreground. It just doesn't work when you lock your device. I test this by moving the app to the background and then locking my device and checking the logs in Android Studio.
Description
Version used:2.10.0-beta01
Devices/Android versions reproduced on: SDK35, Google Pixel
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)