title: Unable to observe livedata set in viewmodel from activity
body: <p>I am a newbie Android developer, and I am trying to observe a boolean set in the ViewModel from its parent's activity. I can observe its initial state as soon as the app launches, but any change applied later on doesn't seem to trigger the observer (i.e. when I switch the fragments).</p>
  <p>Here is the code for my ViewModel:</p>
  <pre><code>class MyMusicViewModel  : ViewModel() {
  
  
      private var _MyMusicViewOn = MutableLiveData&lt;Boolean&gt;()
      val MyMusicViewOn: LiveData&lt;Boolean&gt; get() = _MyMusicViewOn
  
  
  
      init {
          Timber.i(&quot;MyMusicViewModel Init Called!&quot;)
          setMyMusicView(true)
      }
  
      override fun onCleared() {
          super.onCleared()
          Timber.i(&quot;MyMusicViewModel Cleared!&quot;)
          setMyMusicView(false)
      }
  
  
      fun setMyMusicView(setter: Boolean) {
          Timber.i(&quot;MyMusicViewModel setter called! %s&quot;, setter)
          _MyMusicViewOn.value = setter
      }
  
  
  }
  </code></pre>
  <p>And here is its parent's activity:</p>
  <pre><code>class FullscreenActivity : AppCompatActivity() {
  
  
      private val viewModel: MyMusicViewModel by viewModels()
  
    
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
  
         
          viewModel.MyMusicViewOn.observe(this, Observer { MyMusicViewOn -&gt;
              Timber.i(&quot;Observer called for MyMusicViewOn %s&quot;, MyMusicViewOn)
          })
  
      }
  
  }
  </code></pre>
  <p>And in case you wanna see the ViewModel's related fragment, here it is:</p>
  <pre><code>class MyMusicFragment : Fragment() {
  
      private lateinit var viewModel: MyMusicViewModel
  
      override fun onCreateView(
          inflater: LayoutInflater, container: ViewGroup?,
          savedInstanceState: Bundle?
      ): View? {
          // Inflate the layout for this fragment
          val binding = DataBindingUtil.inflate&lt;FragmentMyMusicBinding&gt;(
              inflater,
              R.layout.fragment_my_music,
              container,
              false
          )
          
          viewModel = ViewModelProvider(this).get(MyMusicViewModel::class.java)
  
          return binding.root
      }
      
  
      override fun onResume() {
          super.onResume()
  
          Timber.i(&quot;MyMusicViewFragment resumed!&quot;)
          viewModel.setMyMusicView(true)
  
      }
  
  
  
  
  }
  </code></pre>
  <p>What I am trying to accomplish is to observe the onResume(), onCleared() and init{} functions whenever they are called by changing the status of the MyMusicViewOn MutableLiveData Boolean. What I don't understand is why that boolean doesn't trigger the observer set in the parent activity whenever it changes.</p>
  <p>Thankyou in advance for any thoughts!</p>
  <p>All the best,</p>
  <p>Fab.</p>