Tutorial by Examples

@Module class AppModule(val app: Application) { @Provides @Named("the_answer") fun providesTheAnswer(): Int { return 42 } }
class MyClass{ @field:[Inject Named("the_answer")] lateinit var answer: Int } In Android Development, this is the way in which you inject dependencies into Activity, Fragment or any other object that is instantiated directly by the OS. To learn more about the @field: annotation i...
class MyClass @Inject constructor(@Named val answer: Int){ /* The nuts and bolts of your class */ }

Page 1 of 1