I am currently digging through the Android Room with a View sample app, full source code available here. In this project, an WordViewModel of type AndroidViewModel is defined:
class WordViewModel(application: Application) : AndroidViewModel(application)
Note how the constructor requires an Application instance to be passed in.
Yet when I check the MainActivity, the WordViewModel is retrieved without passing in the
Application instance:
// Get a new or existing ViewModel from the ViewModelProvider.
mWordViewModel = new ViewModelProvider(this).get(WordViewModel.class);
How is that possible, how can the WordViewModel be retrieved without passing in the Application instance and without using a custom factory?