0

I'm migrating from Hilt to Koin.

With Hilt I'm doing the following for injecting LocationTracker:

@Module
@InstallIn(SingletonComponent::class)
object LocationModule {
    @Provides
    @Singleton
    fun providesFusedLocationProviderClient(application: Application): FusedLocationProviderClient =
        LocationServices.getFusedLocationProviderClient(application)

    @Provides
    @Singleton
    fun providesLocationTracker(
        fusedLocationProviderClient: FusedLocationProviderClient,
        application: Application
    ): LocationTracker = LocationTracker(
        fusedLocationProviderClient = fusedLocationProviderClient,
        application = application
    )
}

But with koin I don't know how to inject Application in order to be able to inject FusedLocationProviderClient.

So, how can I inject Application to end up injecting LocationTracker???

1 Answer 1

1

In Koin, you can get the application instance using androidApplication().

https://insert-koin.io/docs/reference/koin-android/get-instances/#android-scope--android-context-resolution

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.