当CoroutineWorker被取消时得到通知

时间:2019-10-15 09:08:30

标签: android android-workmanager

developersite中所述,CoroutineWorker会自动处理工作程序停止,但我想在我的CoroutineWorker停止工作时收到通知,原因是由于工作程序进入工作后网络关闭或工作程序内部未处理的崩溃而导致。

WorkManager lib版本:2.0.1

下面是关闭设备wifi网络时“工作人员”被取消的日志。

I/WM-WorkerWrapper: Work [ id=0c1a2916-d973-4553-adb9-cd7dd6ee9338, tags={ 1DY8EEW0HMH5W7S3, com.xyz.abc.CloudWorker } ] was cancelled
java.util.concurrent.CancellationException: Task was cancelled.
at androidx.work.impl.utils.futures.AbstractFuture.cancellationExceptionWithCause(AbstractFuture.java:1184)
at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:514)
at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:475)
at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:290)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)

0 个答案:

没有答案