ActivityRetainedComponent@ActivityRetainedScope和dagger-hilt android中ActivityComponent@ActivityScope的区别是什么
ActivityRetainedComponent@ActivityRetainedScope和dagger-hilt android中ActivityComponent@ActivityScope的区别是什么,android,dependency-injection,dagger,dagger-hilt,Android,Dependency Injection,Dagger,Dagger Hilt,ActivityRetainedComponent@ActivityRetainedScope与dagger hilt android中ActivityScope的ActivityComponent@ActivityScope之间的区别是什么ActivityRetainedComponent存在于配置更改中,因此它是在第一次onCreate和最后一次onDestroy创建的,当您在ActivityRetainedComponent中用@ActivityRetainedScope标记依赖项时,它保
ActivityRetainedComponent@ActivityRetainedScope与dagger hilt android中ActivityScope的ActivityComponent@ActivityScope之间的区别是什么
ActivityRetainedComponent
存在于配置更改中,因此它是在第一次onCreate和最后一次onDestroy创建的,当您在ActivityRetainedComponent
中用@ActivityRetainedScope
标记依赖项时,它保证您的对象将是一个单例,并在配置更改中存在。但是ActivityComponent
在onCreate
创建,并在onDestroy
销毁。当你用@ActivityScope
标记你在ActivityComponent
中的依赖项时,它保证你的对象将是一个单例,但ActivityComponent
将在配置更改中被销毁。@ActivityRetainedScope将安全防范配置更改,如屏幕方向的更改,语言通道