Pass Context Or Activity To Adapter Using Dagger 2
I inject an Adapter using Dagger 2 without context and it is working, but I am not able to do when I am passing context parameter. Error is coming like this error: android.content
Solution 1:
You have told dagger, that you are providing a specific context:
@ActivityContext
Context provideContext();
And then you are asking dagger to inject your adapter with another type of context - one, which is not annotated with @ActivityContext
.
Instead, you should explicitly define, that you are willing to provide exactly that type of context:
@Inject
public ConversationAdapter(..., @ActivityContext Context context) {
...
}
Post a Comment for "Pass Context Or Activity To Adapter Using Dagger 2"