07-20-2023, 03:44 PM
**[Koin][1]** is a new, lightweight library for DI and can be used in Android as well as in standalone kotlin apps.
Usually you inject dependencies like this:
class SplashScreenActivity : Activity() {
val sampleClass : SampleClass by inject()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}
with the `inject()` method.
But what about injecting stuff in places where Activity context is not available i.e. **outside of an Activity**?
[1]:
Usually you inject dependencies like this:
class SplashScreenActivity : Activity() {
val sampleClass : SampleClass by inject()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}
with the `inject()` method.
But what about injecting stuff in places where Activity context is not available i.e. **outside of an Activity**?
[1]:
[To see links please register here]