Is WorkManager's PeriodicWorkRequest really repeating for anyone?

拟墨画扇 提交于 2019-12-23 12:27:37

问题


I have tried making a repeated task every 15 minutes but Worker#doWork NEVER gets called, not even the very first time (on Nexus 6P - Android 8). However, when testing on an Android 8 emulator, I observed that it gets called the first time pretty soon after the work is scheduled, however it never repeats again. What did I do wrong?

build.gradle:

implementation "android.arch.work:work-runtime-ktx:1.0.0-alpha07"

kotlin code:

            val work = PeriodicWorkRequestBuilder<WidgetUpdateWorker>(MIN_PERIODIC_INTERVAL_MILLIS, TimeUnit.MILLISECONDS)
                .addTag(TAG_UPDATE_WIDGET)
                .build()

        WorkManager.getInstance().enqueueUniquePeriodicWork(TAG_UPDATE_WIDGET,
                ExistingPeriodicWorkPolicy.KEEP,
                work)

回答1:


Replace your app build dependency with below one. PeriodicWork has been working fine in my app. I have tested the app on many devices but not all devices. Do check and let me know if you are facing the problem with any device.

implementation "android.arch.work:work-runtime-ktx:1.0.0-alpha10"


来源:https://stackoverflow.com/questions/52118515/is-workmanagers-periodicworkrequest-really-repeating-for-anyone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!