title: Retaining ViewModel in fragments
body: <p>I'm collaborating with <code>ViewModel</code> and fragments, and would like to retain my <code>ViewModel</code> for my fragment on rotation change. When passing my <code>Fragment</code> into <code>ViewModelProviders.of()</code> it does not get retained, but when I pass the <code>Activity</code> that the fragment belongs to, it is retained. So is passing the activity how it is supposed to be used? 
  Calling <code>ViewModelProviders.of(this)</code> in <code>Fragment</code> won't retain my <code>ViewModel</code>. Is that expected behavior?</p>
  
  <pre><code>class MainFragment : Fragment() {
  
      private lateinit var viewModel: MainViewModel
  
      fun OnXXXXXXXXX {
          // This _will NOT_ retain ViewModel
          viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java)
  
          // This _will_ retain ViewModel
          viewModel = ViewModelProviders.of(activity).get(MainViewModel::class.java)
      }
  }
  </code></pre>