Sam
10/25/2018, 7:09 PM@Module
class AppModule {
@Provides
@Singleton
@Named("application context" )
fun provideContext( app : Application ) : Context = app
@Provides
@Singleton
fun provideWindowManager( @Named( "application context" ) context : Context ) : WindowManager {
...
}
}
or
@Qualifier
@Documented
@Retention(AnnotationRetention.RUNTIME)
annotation class ApplicationContext
@Module
class AppModule {
@Provides
@Singleton
@ApplicationContext
fun provideApplicationContext( app : Application ) : Context = app
@Provides
@Singleton
fun provideWindowManager( @ApplicationContext context : Context ) : WindowManager {
...
}
}