gpt4 book ai didi

android - 为什么工作管理器中的 worker 仍然处于 ENQUEUED 状态?

转载 作者:太空宇宙 更新时间:2023-11-03 10:58:30 24 4
gpt4 key购买 nike

我正在使用 NetworkType.CONNECTED 约束创建 OneTimeWorkRequest,但即使设备已连接到互联网,请求仍处于 ENQUEUED 状态

Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build();

OneTimeWorkRequest request = new OneTimeWorkRequest.Builder(SyncWorker.class)
.setConstraints(constraints)
.build();

WorkContinuation continuation = mWorkManager.beginUniqueWork("work",
ExistingWorkPolicy.KEEP, request);

continuation.enqueue();

最佳答案

试试这个?

Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build();

OneTimeWorkRequest request = new OneTimeWorkRequest.Builder(SyncWorker.class)
.setConstraints(constraints)
.build();

WorkManager.getInstance().enqueue(request);

关于android - 为什么工作管理器中的 worker 仍然处于 ENQUEUED 状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51148201/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com