How to scope ViewModels properly?
问题 I am trying to wrap my head around the new Android Architecture Components, specifically the ViewModel. My impression is that a Fragment should not know about what Activity or Fragment it is owned by, so that it can be used in different contexts of the application. The examples seem to contradict this by declaring the ViewModel scope directly in the Fragment, rather than the Fragment owner: viewModel = ViewModelProviders.of(getActivity()).get(SomeViewModel.class); I would like to be able to