I spend several hours for searching but I still don't find any clearly example about Constructor Injection with Dagger 2.
Assume I have below declaration, how can I create an instance of class B somewhere using Dagger 2 injection?
@Module
public class ClassA {
@Provides public ClassA provideA(){
return new ClassA();
}
}
public class ClassB{
private ClassA a;
@Inject public ClassB(ClassA a){
this.a = a;
}
}
If you have
Then you'll need
And then you can either access like so
Or
And