Using ViewModel and LiveData


#1

I’m made a project for school very similar to the Criminal Activity. I’m adding the MasterDetail feature and using the techniques in this chapter.

Question do I still need a callback interface to talk between the fragments if I’m using ViewModel and LiveData?

I’m going to experiment a bit more but was curious on this. My detail fragment already communicates with my main fragment without implementing the callback interface on the detail fragment.

Thank you.


#2

Okay tried without using the interface but got a null pointer exception I suspect is because I’m not assigning the Main Activity’s Context on onAttached. So it seems I should still use the interface just to connect the hosting activity with main fragment?