匕首和登录凭证

我正在寻找一种方式来创建一个Dagger2组件来密码验证后存储UserCredentials

我有3个活动 – >登录,首页,关于

我想在登录密码验证后创建一个LoggedUser组件,而不是@Inject这个UserLogged在家里和关于,即时尝试避免多个数据库访问(我的情况要求),比当用户单击关闭主页或关于活动时,它返回登录和销毁用户登录,并重新启动进程,但即时通讯有点失去了如何创建一个自定义组件的@ActivityScope在登录创建,但在登录销毁

Curreclty im使用Kotlin + MVP和Injecting Field在演示者中以这种方式:

init { println("Presenter Init: " + javaClass.simpleName) MyApplicationCloudant.getAppComponent().inject(this) } 

该组件是以这种方式构建的:

 component = DaggerAndroidComponent.builder() .androidModule(AndroidModule(this)) .build() 

我的AndroidModule:

 @Module class AndroidModule(private val application: PontotelApplicationCloudant) { /** * Allow the application context to be injected but require that it be annotated with * [@Annotation][ForApplication] to explicitly differentiate it from an activity context. */ @Provides @Singleton // @ForApplication fun provideApplicationContext(): Application { return application } @Provides @Singleton fun provideLocationManager(): LocationManager { return application.getSystemService(LOCATION_SERVICE) as LocationManager } .... } 

我的AndroidComponent

 @Singleton @Component(modules = arrayOf(AndroidModule::class)) interface AndroidComponent { fun inject(application: MyApplicationCloudant) fun inject(loginPresenter: loginPresenter) fun inject(homePresenter: HomePresenter) fun inject(aboutPresenter: aboutPresenter) }