androidandroid-workmanager

Is it possible the android OS cancel my worker of Workmanager?


In my CoroutineWorker.doWork() of an OneTimeWork, a CancellationException was caught. But I am sure I never cancel it.

Is it possible the android OS cancel my worker? If so, where can I find the official documents?


Solution

  • Yes it can get cancelled, for example if you start a work manager with an existing policy of REPLACE it will cancel the current one and create a new one so if its running at that time you will get the exception.

    Also if your task runs for too long it can get cancelled too