Android Dependency Injection with Dagger 2 suggest change

Request Dependencies in Dependent Objects

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:



Table Of Contents