Skip to content
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

How does MainActivityComponent get a MainActivity context? #1

Open
nikiJava opened this issue Jul 8, 2017 · 2 comments
Open

How does MainActivityComponent get a MainActivity context? #1

nikiJava opened this issue Jul 8, 2017 · 2 comments

Comments

@nikiJava
Copy link

nikiJava commented Jul 8, 2017

How does MainActivityComponent get a MainActivity context?
We can use @BindsInstance method in inner Builder interface in MainActivityComponent (Subcomponent) and specify MainActivity (or Context) as parameter or just send MainActivity's Context in constructor of MainActvityModule. But I can not find where in your sample app you send the MainActivity's context. Could you explain me, please?

@iammert
Copy link
Owner

iammert commented Jul 9, 2017

You don't need to do it. Dagger is already doing that for your. You can directly use your MainActivity in you module.

public class MainActivityModule{
       @Provides
       public MainView providesMainView(MainActivity activity) {...}
}

@ghost
Copy link

ghost commented Jul 30, 2017

I am getting error bellow. what is the problem. I did what you did in post.
Error:(29, 10) error: ....ui.main.MainActivityComponent.Builder cannot be provided without an @Provides-annotated method......ui.main.MainActivityComponent.Builder is injected at .......ActivityBuilder.bindMainActivity(builder)java.util.Map<java.lang.Class<? extends android.app.Activity>,javax.inject.Provider<dagger.android.AndroidInjector.Factory<? extends android.app.Activity>>> is injected atdagger.android.DispatchingAndroidInjector.(injectorFactories)dagger.android.DispatchingAndroidInjector<android.app.Activity> is injected at ....MYApp.activityDispatchingAndroidInjector ....MYApp is injected at .....di.AppComponent.inject(app)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants