Skip to content

Instantly share code, notes, and snippets.

@DivS-15
Created July 13, 2022 18:08
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 DivS-15/923e447f0b9b5af71068d7d614f5698d to your computer and use it in GitHub Desktop.
Save DivS-15/923e447f0b9b5af71068d7d614f5698d to your computer and use it in GitHub Desktop.
@Module
@InstallIn(SingletonComponent::class)
object WorkManagerInitializer : Initializer<WorkManager> {
@Provides
@Singleton
override fun create(@ApplicationContext context: Context): WorkManager {
val configuration = Configuration.Builder().build()
WorkManager.initialize(context, configuration)
Log.d("Hilt Init", "WorkManager initialized by Hilt this time")
return WorkManager.getInstance(context)
}
override fun dependencies(): List<Class<out Initializer<*>>> {
// No dependencies on other libraries.
return emptyList()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment