Questions tagged [androidinjector]
11 questions
4
votes
0 answers
Using AndroidInjector (Dagger 2.10) to inject a Service inside a library
According to dagger.android we could use AndroidInjector to inject any Android component, in this case I'm looking to inject a Service using either DaggerIntentService or calling directly AndroidInjection.inject(this) in my service. I understand…

JavierSP1209
- 899
- 8
- 17
3
votes
3 answers
Why AdnroidInjector.inject(fragment) uses deprecated android.support.v4.app.Fragment
I'm using Dagger2 for DI in android app,
I want inject viewModel in a fragment by AndroidInjector and have this two line :
AndroidInjection.inject(this)
viewModel = ViewModelProviders.of(this,…

beigirad
- 4,986
- 2
- 29
- 52
2
votes
1 answer
Dagger 2 Injector and Binds IntoMap with IntKey
I'm using Dagger 2 Android injector to inject my Activities and Fragments.
I have a generic RecyclerView Adapter and keeping ViewHolderFactories and Binders in a Map.
Here's my adapter:
@Module
class CorePresentationModule {
@Provides
fun…

savepopulation
- 11,736
- 4
- 55
- 80
1
vote
1 answer
How to get Activity Instance in Module class using AndroidInjector?
I have sample project in which I am using dagger-android AndroidInjector to Inject dependencies.
In this sample app I have a class Navigator which does all the Activity to Activity navigation and it requires the instance of current Activity in it's…

Tushar Purohit
- 524
- 7
- 25
1
vote
0 answers
Is this really the best form of inject something with dagger 2? or why dagger is a good option?
I am trying to use Dagger 2, and in a lot of examples I saw code like this:
MyComponent.java
@Singleton
@Component(modules = {SharedPrefModule.class})
public interface MyComponent {
void inject(MainActivity…

Tlaloc-ES
- 4,825
- 7
- 38
- 84
1
vote
1 answer
@Provides methods in SubComponent with AndroidInjector and Kotlin
I'm using the Dagger2 AndroidInjector and Kotlin. I have a subcomponent with its module defined in this way:
@Subcomponent(modules = arrayOf(
UIModule::class,
HomeActivitySubcomponent.ComponentModule::class
))
interface…

kingston
- 11,053
- 14
- 62
- 116
0
votes
1 answer
how to provide dynamic String such as ( server response ) in module?
i recently used from New Android Injector with Dagger 2 in my project and i have an issue :
i want provide a dynamic String with dagger and i don't know how do this;
i receive a token from server and need to pass this as field to and instance of…

Ali Sheykhi
- 23
- 9
0
votes
1 answer
Can not provide context for dagger injection
I'm new in dagger , I want to inject context and network (using retrofit) in my classes .
this is my code so far :
@Module
// Safe here as we are dealing with a Dagger 2 module
@Suppress("unused")
object NetworkModule {
@Provides
…

Navid Abutorab
- 1,667
- 7
- 31
- 58
0
votes
1 answer
Using AndroidInjector for generic Activity/Fragment
There is a generic fragment
public class MyFragment extends Fragment {
@Inject
SomeClass class;
public MyFragment(){}
}
}
I am not able to add this Fragment to the Fragment Binding Module as Dagger complains it is of raw type.
How do I…

Sunny
- 7,444
- 22
- 63
- 104
0
votes
1 answer
Unused @Binds methods with Dagger
I have the following definition of the Splash screen Activity:
@Subcomponent(modules = arrayOf(
SplashActivitySubcomponent.ComponentModule::class)
)
interface SplashActivitySubcomponent : AndroidInjector {
…

kingston
- 11,053
- 14
- 62
- 116
0
votes
1 answer
Passing object to module with new Android injection
I'm using the new Android injection from dagger 2.11, and i have this simple module :
@Module
public class MyModule{
@MyScope
@Provides
SomeClass provideSomeClass(Context context){
return new SomeClass(context);
}
}
as you can see i need to…

Mahdi Nouri
- 1,391
- 14
- 29