const val WORK_ID = "MDM-WORKER-SYSTEM-INFO" private const val REPEAT_INTERVAL_HOUR = 30L private const val FLEX_INTERVAL_MINUTES = 15L fun enqueue(context: Context) { val periodicWorkRequest = PeriodicWorkRequestBuilder<SystemInfoWorker>( REPEAT_INTERVAL_HOUR, TimeUnit.MINUTES, FLEX_INTERVAL_MINUTES, TimeUnit.MINUTES ).apply { addTag(WORK_ID) }.build() val workManager = WorkManager.getInstance(context) workManager.enqueueUniquePeriodicWork( WORK_ID, ExistingPeriodicWorkPolicy.REPLACE, periodicWorkRequest ) } } }