Android & Jetpack Compose (50 Qs)•Part 3: ART Internals, Memory Leak Profiling & Production Hardening (25 - 35)
Dependency Injection with Hilt / Dagger: Scopes, Component Lifecycles, and `@HiltViewModel`.
senior LevelMost AskedDependency InjectionComponentsLifecycle
In Simple Words: Hilt simplifies Dagger on Android by providing standard, pre-defined dependency scopes tied directly to Android OS component lifecycles:
@Singleton: Survives the entire application lifetime (SingletonComponent).@ActivityRetainedScoped: Survives configuration changes (screen rotations) alongside ViewModels.@ActivityScoped: Destroyed when the Activity is destroyed.@HiltViewModel: Injects repositories, use-cases, andSavedStateHandledirectly into ViewModels with zero factory boilerplate.