In Android Components could I make application class as the owner of ViewModel so I use it across several activities? or there no walk around?
ViewModelProviders.of(application class not activity).get(MyViewModel.class);
In Android Components could I make application class as the owner of ViewModel so I use it across several activities? or there no walk around?
ViewModelProviders.of(application class not activity).get(MyViewModel.class);
An Application
is not a LifecycleOwner
, so you cannot use it as a scope for a ViewModel
.