title: What are the differences between ViewModelProvider.Factory and ViewModelProvider.NewInstanceFactory?
body: <p>I'm currently transforming my project architecture from MVP to MVVM. When I'm working on it, I find something made me confused:</p>
  
  <p>In <code>ScheduleViewModelFactory.kt</code> of project <a href="https://github.com/google/iosched/blob/2696fc7e06826ba2db72de243f0d63f83f4a29b5/tv/src/main/java/com/google/samples/apps/iosched/tv/ui/schedule/ScheduleViewModelFactory.kt" rel="noreferrer">iosched</a>, the factory implements <strong>ViewModelProvider.Factory:</strong></p>
  
  <pre><code>class ScheduleViewModelFactory(
      private val userEventRepository:DefaultSessionAndUserEventRepository
  ) : ViewModelProvider.Factory {
  
      @Suppress("UNCHECKED_CAST")
      override fun &lt;T : ViewModel&gt; create(modelClass: Class&lt;T&gt;): T {
          if (modelClass.isAssignableFrom(ScheduleViewModel::class.java)) {
              return ScheduleViewModel(LoadUserSessionsByDayUseCase(userEventRepository)) as T
          }
          throw IllegalArgumentException("Unknown ViewModel class")
      }
  }
  </code></pre>
  
  <p>In <code>DetailViewModelFactory.java</code> of project Sunshine from <a href="https://codelabs.developers.google.com/codelabs/build-app-with-arch-components/index.html?index=..%2F..%2Findex#2" rel="noreferrer">codelab</a>, the factory extends <strong>ViewModelProvider.NewInstanceFactory:</strong> </p>
  
  <pre><code>public class DetailViewModelFactory extends ViewModelProvider.NewInstanceFactory {
  
      private final SunshineRepository mRepository;
      private final Date mDate;
  
      public DetailViewModelFactory(SunshineRepository repository, Date date) {
          this.mRepository = repository;
          this.mDate = date;
      }
  
      @Override
      public &lt;T extends ViewModel&gt; T create(Class&lt;T&gt; modelClass) {
          //noinspection unchecked
          return (T) new DetailActivityViewModel(mRepository, mDate);
      }
  }
  </code></pre>
  
  <p>I would like to know:</p>
  
  <ol>
  <li>What are the differences between <strong>ViewModelProvider.Factory</strong> and <strong>ViewModelProvider.NewInstanceFactory</strong>? </li>
  <li>Why they are being used like the codes mentioned above?</li>
  <li>What is the best practice/scenario to use each of them?</li>
  </ol>