title: ViewModelProviders.of(activity) only accept fragment or fragmentactivity
body: <p>i have a problem using mvvm in splash activity and relate the viewmodel to the activity,i don't won't to create fragment for it .
  in AppCompatActivity:</p>
  <pre><code>fun &lt;T : ViewModel&gt; AppCompatActivity.obtainViewModel(viewModelClass: Class&lt;T&gt;) =
      ViewModelProviders.of(this, ViewModelFactory.getInstance(application)).get(viewModelClass)
  </code></pre>
  <p>it says that .of(this,factor) only accept fragment and fragmentActivity
  i already read  <a href="https://stackoverflow.com/questions/47698034/viewmodel-cannot-be-instantiated-in-an-activity">link</a> but it doesn't solve the problem
  my build.grable:</p>
  <pre><code>apply plugin: 'com.android.application'
  
  apply plugin: 'kotlin-android'
  apply plugin: 'kotlin-kapt'
  
  apply plugin: 'kotlin-android-extensions'
  
  android {
      compileSdkVersion 28
      defaultConfig {
          applicationId &quot;com.attendance.myproject.begory&quot;
          minSdkVersion 21
          targetSdkVersion 27
          versionCode 1
          versionName &quot;1.0&quot;
          testInstrumentationRunner &quot;android.support.test.runner.AndroidJUnitRunner&quot;
      }
      compileOptions {
          sourceCompatibility JavaVersion.VERSION_1_8
          targetCompatibility JavaVersion.VERSION_1_8
      }
  
      // to prevent the addition of jvm-target
      kotlinOptions {
          jvmTarget = JavaVersion.VERSION_1_8.toString()
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
      buildFeatures {
          dataBinding true
      }
  }
  
  dependencies {
      def room_version = &quot;2.2.3&quot; // check latest version from docs
  
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      implementation &quot;org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10&quot;
      implementation &quot;androidx.recyclerview:recyclerview:$rootProject.recyclerViewVersion&quot;
      implementation &quot;androidx.cardview:cardview:$rootProject.cardViewVersion&quot;
      implementation &quot;androidx.constraintlayout:constraintlayout:2.0.2&quot;
      //noinspection GradleCompatible
  
      implementation 'androidx.appcompat:appcompat:1.3.0-alpha02'
  //room
  
      implementation &quot;androidx.room:room-runtime:$room_version&quot;
      kapt &quot;androidx.room:room-compiler:$room_version&quot;
  
      implementation &quot;com.google.android.material:material:1.3.0-alpha03&quot;
      implementation 'androidx.navigation:navigation-fragment-ktx:2.3.1'
      implementation 'androidx.navigation:navigation-ui-ktx:2.3.1'
      testImplementation 'junit:junit:4.13'
      androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
      implementation 'com.google.firebase:firebase-core:17.5.1'
      implementation 'com.google.firebase:firebase-auth:19.4.0'
      implementation 'com.google.firebase:firebase-database:19.5.1'
      implementation 'com.firebase:firebase-client-android:2.3.1'
      implementation 'com.google.code.gson:gson:2.8.5'
      implementation 'me.dm7.barcodescanner:zxing:1.9.8'
  
      //    Add Zxing library to generate barcode
      implementation 'com.google.zxing:core:3.2.1'
      implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
      implementation &quot;org.jetbrains.kotlin:kotlin-script-runtime:1.4.10&quot;
      //curved bottom navigation
      implementation 'np.com.susanthapa.curved_bottom_navigation:curved_bottom_navigation:0.6.3'
  
      implementation &quot;androidx.lifecycle:lifecycle-extensions:$archLifecycleVersion&quot;
      kapt &quot;androidx.lifecycle:lifecycle-compiler:$archLifecycleVersion&quot;
      implementation &quot;androidx.core:core-ktx:1.3.2&quot;
      implementation &quot;androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0&quot;
      implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
      implementation'android.arch.lifecycle:extensions:1.1.1'
  }
  apply plugin: 'com.google.gms.google-services'
  </code></pre>
  <p>I'm using androidx and the activity is extended from the appcompatActivitty .I had initiate the viewmodel in the on create fun .</p>
  <pre><code>override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_splash)
      if(!Internet.isOnline(applicationContext)) showMessage(getString(R.string.no_internet_connection))
  
      binding= DataBindingUtil.setContentView(this, R.layout.activity_splash)
      splashViewModel = obtainViewModel()
      binding.splashViewModel
      subscribeToNavigationChanges(splashViewModel)
  
  }
  </code></pre>
  <p>I really takes days searching in this problem if any one can help it will be very thankful.</p>