Periodicworkrequest not working in newer version of android

Viewed 1248

I am not able to call periodic work once in 16mins.It only calls when i run the app in the device. Check the code below if i am doing any mistake.I am using One-plus 7t device.

Scope:I am trying to upload data present in Room Database to server once in 16mins.

val constraints = Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build()

    val repeatingRequest = PeriodicWorkRequestBuilder<RefreshDataWorker>(16, TimeUnit.MINUTES)
            .setConstraints(constraints)
            .build()

    WorkManager.getInstance().//enqueue(repeatingRequest)
    enqueueUniquePeriodicWork(
            RefreshDataWorker.WORK_NAME,
            ExistingPeriodicWorkPolicy.KEEP,
            repeatingRequest)

And Dependency

implementation "androidx.work:work-runtime-ktx:2.3.4"
1 Answers
Related