title: Hilt: Why is ActivityRetainedScoped vs ViewModelScoped
body: <p>I'm trying to understand why is <code>ActivityRetainedScoped</code> introduced for DI in Hilt. It looks to me that the scope is identical to what <code>ViewModelScoped</code> should do. I was under the impression that scoped worked like this:</p>
  <p><code>AppScope (singleton) &gt; ViewModelScope &gt; ActivityScope &gt; ViewScope &gt; ...</code></p>
  <p>But <a href="https://developer.android.com/images/training/dependency-injection/hilt-hierarchy.svg" rel="nofollow noreferrer">this graphic</a> kinda hints that ViewModel and Activity scopes are... siblings?</p>
  <p>According to the docs:</p>
  <blockquote>
  <p>&quot;ActivityRetainedComponent lives across configuration changes, so it
  is created at the first Activity#onCreate() and destroyed at the last
  Activity#onDestroy().&quot;</p>
  </blockquote>
  <p>Well, so does the view model, no?
  I'm pretty sure view models survive config changes (that's the whole point if having them in the first place)</p>
  <p>What is <code>ActivityRetainedScoped</code>? How is it different from VM scope? Why does google likes over complicating things that should be conceptually simple</p>
  <p><a href="https://developer.android.com/training/dependency-injection/hilt-android" rel="nofollow noreferrer">https://developer.android.com/training/dependency-injection/hilt-android</a></p>