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
???
In Koin, you can get the application instance using androidApplication()
.