This is the code from my Fragment:
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
...
viewModel.myLiveData.observe(viewLifecycleOwner) { data ->
...
}
...
}
I noticed that when I come back to my fragment from others fragments (example back navigation) myLiveData is automatically refreshed. In addition onViewCreated also is re-called, so the code inside the observe is executed twice.
Why? viewLifecycleOwner is not correct ?