[英]App_HiltComponents.ActivityC scoped with @dagger.hilt.android.scopes.ActivityScoped may not reference bindings with different scopes
[英]What is difference between ActivityRetainedComponent @ActivityRetainedScope and ActivityComponent @ActivityScoped in dagger hilt android
根据文件。 ActivityRetainedComponent
存在于配置更改中,因此它是在第一次 onCreate 和最后一次 onDestroy 时创建的,并且当您在ActivityRetainedComponent
使用@ActivityRetainedScope
标记您的依赖项时,它保证您的对象将成为单例并在配置更改后继续存在。 但是ActivityComponent
在onCreate
创建并在onDestroy
销毁。 当您在ActivityComponent
使用@ActivityScope
标记您的依赖项时,它保证您的对象将是单例,但ActivityComponent
将在配置更改中被销毁。
@ActivityRetainedScope 将防止配置更改,例如屏幕方向更改、语言更改
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.