I have two ViewModels. One is used from the Fragment only and the other one is a shared ViewModel from the Activity.
Fragment:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
viewModel = ViewModelProviders.of(this).get(FragmentViewModel.class);
...
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
activityViewModel = ViewModelProviders.of(getActivity()).get(ActivityViewModel.class);
}
But in order to know if I can use the content from the activity's ViewModel, I need to know if the onActivityCreated(...)
is called after onViewCreated(...)
so I can request my data in the Fragment ViewModel based on data I have in the Activity's ViewModel.
To summarise:
Is it for certain that onActivityCreated(...)
is called after onViewCreated(...)
has finished?