Skip to content

Instantly share code, notes, and snippets.

@tobioyelekan
Created May 24, 2020 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobioyelekan/6c2e36a7f5d5758a0be5cd86759a8dc2 to your computer and use it in GitHub Desktop.
Save tobioyelekan/6c2e36a7f5d5758a0be5cd86759a8dc2 to your computer and use it in GitHub Desktop.
class ApplicationClass : Application() {
override fun onCreate() {
super.onCreate()
val constraint = Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
val workManager = WorkManager.getInstance(applicationContext)
val request = PeriodicWorkRequest.Builder(WorkManagerClass::class.java,
PeriodicWorkRequest.MIN_PERIODIC_INTERVAL_MILLIS, TimeUnit.MINUTES)
.setConstraints(constraint)
.build()
workManager.enqueue(request)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment