title: How to get ViewModel in Activity in Android SunFlower Project?
body: <p>I am studying <code>MVVM</code> of Google <a href="https://github.com/android/sunflower" rel="nofollow noreferrer">Android SunFlower</a> project.</p>
  
  <p>For <code>Fragment</code>, it gets <code>viewmodel</code> like the following</p>
  
  <pre><code>private val plantDetailViewModel: PlantDetailViewModel by viewModels {
          InjectorUtils.providePlantDetailViewModelFactory(requireActivity(), args.plantId)
      }
  </code></pre>
  
  <p>I want to try the same method to get <code>viewmodel</code> in Activity. but the <code>requireActivity()</code>show unresolved reference...</p>
  
  <p>And the <code>data binding</code> is not working when I replace it to <code>this</code>.</p>
  
  <p>Does it has other pattern can be use for <code>providePlantDetailViewModelFactory()</code></p>
  
  <p>Thanks in advance.</p>