Any example of Dagger 2 static injections. I have already tried this : -
class A{
@Inject
static B b;
static {
getAppInstance().getComponent().inject(A.class);
}
static anyMethod(){
b.anotherMethod();
}
}
public interface AppComponent{
void inject(Class<A> aClass);
}
So this is my proposed answer: -
class A{
private static B b = getAppInstance.getComponent().getB();
static anyMethod(){
b.anotherMethod();
}
}
public interface AppComponent{
B getB();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With