# dagger


11/04/2020, 1:07 PM
Scenario I have an Activity called Activity1, then inside has a Fragment1 all have the
and then if my Activity2 wants to inject Fragment1 Why I need to implement HasAndroidInjector and do the
Copy code
@Inject lateinit var androidInjector: DispatchingAndroidInjector<Any>
override fun androidInjector(): AndroidInjector<Any> = androidInjector
to be able to use a Fragment that is already with
? If I remove this two lines it says :
RunTimeException:Unable to resume activity {MyActivity}: java.lang.IllegalArgumentException: No injector factory bound for Class<MyClass>
I thought that if I have this:
Copy code
 modules = [ FragmentProvider::class]
fun bindMyActivity2: Activity2
It would work anyways, because I've add as a modules a module that has inside the
with that Fragment... Is it because I need that `hasAndroidInjector`when I want to provide injection into a inner Fragment?

Colton Idle

11/04/2020, 6:40 PM
Dagger and hilt noob, but I didn't think that was possible (i.e. Injecting a fragment into an activity?)