kotlin-mvp-dagger2
kotlin-mvp-dagger2 copied to clipboard
[Q&A] What if I create another activity
What if I create another activity? For example PostDetailActivity. Should I create a new Module and Component? As in here:
fun inject(mainActivity: MainActivity)
We got MainActivity, if I inject on PostDetailActivity, as injectDependcy()
:
private fun injectDependency() {
val activityComponent = DaggerActivityComponent.builder()
.activityModule(ActivityModule(this))
.build()
activityComponent.inject(this)
}
this
will yield Type mismatch
, required MainActivity
while it required PostDetailActivity
.
you should create a new annotation with the @Qualifier
annotation, or use the @Named(String)
annotation.