-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MvpLceActivity can't see Dagger2 injections #99
Comments
You have to call Also, there is already a field called I would recommend you to take a slightly different approach regarding dependency injection with dagger2. I would recommend to change your code to something like this: public class MyActivity extends MvpLceActivity... {
private MyComponent component;
...
private void injectDependencies(){
myComponent = DaggerMyComponent.create();
....
}
@Override
public void onCreate(Bundle savedInstanceState) {
injectDependencies();
super.onCreate(savedInstanceState);
....
}
@NonNull @Override
public MyPresenter createPresenter() {
return component.getPresenter();
}
...
} |
👍 |
Let me share a solution, which I use for the case if We can use public class MyActivity extends MvpLceActivity... {
@Inject Provider<MyPresenter> myPresenterProvider;
...
@Override
public void onCreate(Bundle savedInstanceState) {
AndroidInjection.inject(this);
super.onCreate(savedInstanceState);
....
}
@NonNull @Override
public MyPresenter createPresenter() {
return myPresenterProvider.get();
}
...
} Here we do injection in Activity by calling just |
I have
MyModule.java
which provides a Presenter for Activity:There is
MyComponent.java
which has:Now i am trying to inject that Presenter in
MyActivity
and use it:It shows error:
The text was updated successfully, but these errors were encountered: