[UPDATE]
这已经在Alpha09中解决了
我有两个被WorkManager Alpha04 beginWith和API链接起来的作品.
fun updateData() { createWorkRequests() runDataDownloaDWork()}private fun createWorkRequests() { DWElementsWork = OneTimeWorkRequestBuilder<DWElementsWork>() .addTag(TAG_ELEMENTS_WORK) .build() DWElementTypesWork = OneTimeWorkRequestBuilder<DWElementTypesWork>() .addTag(TAG_ELEMENTS_TYPE_WORK) .build()}private fun runDataDownloaDWorkNoStatus() { WorkManager.getInstance()!! .beginWith(DWElementTypesWork) .then(DWElementsWork) .enqueue()}
它们在我的MainActivity.kt文件中被调用,并且有些时候只是第一个被执行DWElementTypesWork两次,而在少数情况下它们都没有.我错过了一些配置吗?文档很简单.
这是基于WorkManager日志的logcat输出:
06-28 09:28:20.519 28480-28501/com.myapp.app D/SystemJobScheduler: Scheduling work ID 3e5f8531-aa92-4e28-8533-d180612dab02 Job ID 2806-28 09:28:20.537 28480-28501/com.myapp.app D/GreedyScheduler: Starting tracking for 3e5f8531-aa92-4e28-8533-d180612dab0206-28 09:28:20.542 28480-28501/com.myapp.app D/ConstraintTracker: NetworkStateTracker: initial state = [ Connected=true ValIDated=true Metered=false NotRoaming=true ]06-28 09:28:20.543 28480-28501/com.myapp.app D/NetworkStateTracker: Registering network callback06-28 09:28:20.549 28480-28501/com.myapp.app D/WorkConstraintsTracker: Constraints met for 3e5f8531-aa92-4e28-8533-d180612dab0206-28 09:28:20.550 28480-28501/com.myapp.app D/GreedyScheduler: Constraints met: Scheduling work ID 3e5f8531-aa92-4e28-8533-d180612dab0206-28 09:28:20.551 28480-28501/com.myapp.app D/WorkConstraintsTracker: Constraints met for 3e5f8531-aa92-4e28-8533-d180612dab0206-28 09:28:20.551 28480-28501/com.myapp.app D/GreedyScheduler: Constraints met: Scheduling work ID 3e5f8531-aa92-4e28-8533-d180612dab0206-28 09:28:20.555 28480-28512/com.myapp.app D/NetworkStateTracker: Network capabilitIEs changed: [ Transports: WIFI CapabilitIEs: NOT_METERED&INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN&VALIDATED&FOREGROUND linkUpBanDWIDth>=1048576Kbps linkDnBanDWIDth>=1048576Kbps SignalStrength: -51]06-28 09:28:20.558 28480-28501/com.myapp.app D/Processor: Processor: processing 3e5f8531-aa92-4e28-8533-d180612dab02 Work 3e5f8531-aa92-4e28-8533-d180612dab02 is already enqueued for processing06-28 09:28:20.593 28480-28513/com.myapp.app D/DW_element_types_work: doWork DW_element_types_work06-28 09:28:20.629 28480-28480/com.myapp.app D/SystemJobService: onStartJob for 3e5f8531-aa92-4e28-8533-d180612dab0206-28 09:28:20.630 28480-28501/com.myapp.app D/Processor: Work 3e5f8531-aa92-4e28-8533-d180612dab02 is already enqueued for processing06-28 09:28:20.659 28480-28513/com.myapp.app D/Okhttp: --> GET http://myAPI.com/elements/types --> END GET06-28 09:28:21.086 28480-28513/com.myapp.app D/Okhttp: <-- 200 OK http://myAPI.com/elements/types (426ms) Server: Nginx/1.13.8 Content-Type: application/Json transfer-encoding: chunked X-Powered-By: PHP/7.2.6 Cache-Control: no-cache, private Date: Thu, 28 Jun 2018 07:28:21 GMT06-28 09:28:21.088 28480-28513/com.myapp.app D/Okhttp: [] <-- END http (491-byte body)06-28 09:28:21.291 28480-28513/com.myapp.app D/WorkerWrapper: Worker result SUCCESS for 3e5f8531-aa92-4e28-8533-d180612dab0206-28 09:28:21.296 28480-28513/com.myapp.app D/WorkerWrapper: Setting status to enqueued for 181346ae-2341-45ad-9e90-a8a5e86fffa606-28 09:28:21.305 28480-28513/com.myapp.app D/SystemJobScheduler: Scheduling work ID 181346ae-2341-45ad-9e90-a8a5e86fffa6 Job ID 2906-28 09:28:21.307 28480-28513/com.myapp.app D/GreedyScheduler: Starting tracking for 181346ae-2341-45ad-9e90-a8a5e86fffa606-28 09:28:21.308 28480-28513/com.myapp.app D/WorkConstraintsTracker: Constraints met for 3e5f8531-aa92-4e28-8533-d180612dab0206-28 09:28:21.309 28480-28513/com.myapp.app D/WorkConstraintsTracker: Constraints met for 181346ae-2341-45ad-9e90-a8a5e86fffa606-28 09:28:21.309 28480-28513/com.myapp.app D/GreedyScheduler: Constraints met: Scheduling work ID 3e5f8531-aa92-4e28-8533-d180612dab0206-28 09:28:21.310 28480-28501/com.myapp.app D/Processor: Work 3e5f8531-aa92-4e28-8533-d180612dab02 is already enqueued for processing06-28 09:28:21.310 28480-28513/com.myapp.app D/GreedyScheduler: Constraints met: Scheduling work ID 181346ae-2341-45ad-9e90-a8a5e86fffa606-28 09:28:21.312 28480-28501/com.myapp.app D/Processor: Processor: processing 181346ae-2341-45ad-9e90-a8a5e86fffa606-28 09:28:21.316 28480-28480/com.myapp.app D/Processor: Processor 3e5f8531-aa92-4e28-8533-d180612dab02 executed; isSuccessful = true, reschedule = false06-28 09:28:21.316 28480-28517/com.myapp.app E/WorkerWrapper: Status for 181346ae-2341-45ad-9e90-a8a5e86fffa6 is BLOCKED; not doing any work06-28 09:28:21.317 28480-28480/com.myapp.app D/SystemJobService: 3e5f8531-aa92-4e28-8533-d180612dab02 executed on JobScheduler06-28 09:28:21.319 28480-28480/com.myapp.app D/SystemJobService: onStartJob for 181346ae-2341-45ad-9e90-a8a5e86fffa606-28 09:28:21.320 28480-28501/com.myapp.app D/Processor: Work 181346ae-2341-45ad-9e90-a8a5e86fffa6 is already enqueued for processing06-28 09:28:21.332 28480-28480/com.myapp.app D/Processor: Processor 181346ae-2341-45ad-9e90-a8a5e86fffa6 executed; isSuccessful = false, reschedule = false06-28 09:28:21.333 28480-28480/com.myapp.app D/SystemJobService: 181346ae-2341-45ad-9e90-a8a5e86fffa6 executed on JobScheduler
有时它会为第二个作业抛出以下错误:
E/WorkerWrapper: Status for cfaeae5c-fafd-4b9f-a77b-909625bdb26b is ENQUEUED; not doing any workE/WorkerWrapper: Status for cfaeae5c-fafd-4b9f-a77b-909625bdb26b is BLOCKED; not doing any work
解决方法:
我有同样的问题(我发现你的问题正在搜索它).
它似乎在Google方面被打破了,他们应该修复它.
我稍后会尝试触发错误报告.
现在我通过将工作延迟1秒来“修复”它.如下:
OneTimeWorkRequest.Builder(MyWorker::class.java)// Todo whenever WorkManager is updated, test this again// it was not working without the delay https://stackoverflow.com/questions/51078090/workmanager-chained-work-not-running#.setinitialDelay(1, TimeUnit.SECONDS)
我知道这是一个糟糕的黑客,但现在它的工作原理.
总结以上是内存溢出为你收集整理的Android WorkManager链接的工作未在alpha04上运行全部内容,希望文章能够帮你解决Android WorkManager链接的工作未在alpha04上运行所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)