Search code examples
periodic-taskandroid-workmanager

Is WorkManager's PeriodicWorkRequest really repeating for anyone?


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)

Solution

  • 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"