I am new to the mvvm pattern. I created a ViewModel for the main activity. Now I want to get an instance of the ViewModel in the main activity.
Most Tutorials and answe
For now, the only thing working for me was to use:
MainActivityViewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(MainActivityViewModel.class);
However, I am still thankful for any advice, how this can be done different using new ViewModelProvider(this).get(MainActivityViewModel.class);