Request Dependencies in Dependent Objects

suggest change

Now that you have the providers for your different models, you need to request them. Just as Vehicle needs Motor, you have to add the @Inject annotation in the Vehicle constructor as follows:

@Inject
public Vehicle(Motor motor){
    this.motor = motor;
}

You can use the @Inject annotation to request dependencies in the constructor, fields, or methods. In this example, I’m keeping the injection in the constructor.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Dependency Injection with Dagger 2:
*Request Dependencies in Dependent Objects

Table Of Contents
169XMPP
212Dependency Injection with Dagger 2
230AIDL
242Okio