Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Injection in >= M14 Kotlin code with Dagger2
class ExampleInjectedActivity : Activity() {
@Inject lateinit var controller: ExampleController
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.example_layout)
//controller.doThing() // would compile but throw at runtime
component().inject(this)
controller.doThing() // works, no need for null-safe syntax
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment