本文介绍了为什么工作经理中的工人仍处于入队状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建具有NetworkType.CONNECTED约束的OneTimeWorkRequest,但是即使设备已连接到Internet,请求仍处于已排队"状态
I'm creating OneTimeWorkRequest with NetworkType.CONNECTED constraint, but even though the device is connected to the internet, the request is still in ENQUEUED state
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);
这篇关于为什么工作经理中的工人仍处于入队状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!