abh*_*era 5 android dependency-injection dagger dagger-hilt
android dagger hilt 中的ActivityRetainedComponent @ActivityRetainedScope 和ActivityComponent @ActivityScoped 有什么区别
小智 12
根据文件。ActivityRetainedComponent存在于配置更改中,因此它是在第一个 onCreate 和最后一个 onDestroy 时创建的,当您标记依赖项时,它ActivityRetainedComponent保证@ActivityRetainedScope您的对象将是单例并在配置更改中生存。但ActivityComponent创建于onCreate并销毁于onDestroy。当您ActivityComponent用@ActivityScope它来标记依赖项时,您的对象将是单例,但ActivityComponent会在配置更改中被破坏。
ActivityRetainedComponent
@ActivityRetainedScope
ActivityComponent
onCreate
onDestroy
@ActivityScope
归档时间:
5 年,7 月 前
查看次数:
996 次
最近记录: