Before ViewModel
the best way was to use interface to communicate or pass date between fragments and activity. But, now we can use ViewModel
and it will be very easy. We just need to create the ViewModel in activity scope and thats it. Just observer the ViewModel. This is a sample project to show the Shared ViewModel
implemneteation.
Tutorial and related article on medium.