First of all this is not a duplicate question, I have tried all the other methods found here on SO but they didn't solve my problem. I'm having a problem with the ViewModelProviders. These are my codes.
viewModel = ViewModelProviders.of(this).get(VideoPlayerViewModel::class.java)
The 'this' is giving an error. Here's the error
None of the following functions can be called with the arguments supplied.
of(Fragment) defined in androidx.lifecycle.ViewModelProviders
of(FragmentActivity) defined in androidx.lifecycle.ViewModelProviders
This is my class
class VideoPlayerActivity : Activity() {
private lateinit var viewModel: VideoPlayerViewModel
}
As I said I have read some other answers regarding to this problem and they are telling me to extend AppCompatActivity() instead of Activity(). The problem is when i change to AppCompatActivity() it does solve the error but gives a whole lot of error in my other codes. So i want to do it without changing the Activity(). What is the solution?