android - dagger hilt android中的ActivityRetainedComponent @ActivityRetainedScope和ActivityComponent @ActivityScoped有什么区别
问题描述
dagger hilt android中的ActivityRetainedComponent @ActivityRetainedScope和ActivityComponent @ActivityScoped有什么区别
解决方案
根据文件。ActivityRetainedComponent
存在于配置更改中,因此它是在第一个 onCreate 和最后一个 onDestroy 时创建的,并且当您标记依赖项时ActivityRetainedComponent
,@ActivityRetainedScope
它保证您的对象将是单例并且在配置更改中仍然存在。但是ActivityComponent
在 时创建onCreate
并在 时销毁onDestroy
。当你标记你的依赖时ActivityComponent
,@ActivityScope
它保证你的对象将是一个单例,但ActivityComponent
会在配置更改中被破坏。
推荐阅读
- google-app-engine - Java8 将 appcfg 迁移到 gcloud
- video - Ffmpeg concat demuxer 改变视频流开始时间
- visual-studio-code - Vimspector 如何定义预启动任务
- angular - 当值是对象类型时,离子选择不显示选定的选项
- c# - 播放中最大化的跳跃错误
- asp.net - 更改 xml 输出路径后,ASP.NET Core Web API 解决方案空间充满了许多文件
- python - Python:挖掘时序序列的方法
- flutter - 如何在颤动中屏幕记录特定的小部件?
- c - YouCompleteMe 不适用于 C 标头
- intellij-idea - 在 Intellij 中禁用测试编译