https://kotlinlang.org logo
#coroutines
Title
# coroutines
m

Maurice Jouvet

09/04/2020, 2:35 PM
I have a question, it's clearly my misunderstanding, but, I have a JobCancellation on my Workers ($doWork: kotlinx.coroutines.JobCancellationException: Job was cancelled;) Only when my screen is off. If the app is the background or if we are on the app. No problems.
i

Ian Lake

09/04/2020, 3:48 PM
Your jobs will get cancelled if your constraints are no longer met or if JobScheduler's maintenance period ends, that's perfectly normal (and your job will be set to RETRY automatically when cancelled this way)
m

Maurice Jouvet

09/05/2020, 6:30 AM
Yes I understand that, but I don't know or see a screen off constraint..
i

Ian Lake

09/05/2020, 2:41 PM
Keep in mind that in light doze (the state that your device goes into shortly after the screen is turned off), the maintenance windows for doing work while the screen off are very short (~a minute): https://developer.android.com/training/monitoring-device-state/doze-standby#understand_doze
You shouldn't be attempting to handle any CancelationException directly. That's true for any suspending function
👍 1
m

Maurice Jouvet

09/08/2020, 11:38 AM
Ok thanks a lot.
3 Views