title: Observe LiveData from foreground service
body: <p>I have a repository which holds the LiveData object and is used by both
  activity and a foreground service through a ViewModel.
  When I start observing from the activity everything works as expected.
  However observing from the service doesn't trigger the Observe.
  This is the code I use</p>
  
  <pre><code>class MyService: LifecycleService() {
       lateinit var viewModel: PlayerServiceViewModel
  
       override fun onCreate() {
            viewModel = MyViewModel(applicationContext as Application)
       }
  
       override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
            viewModel.getLiveData().observe(this, Observer { data -&gt;
              // Do something with the data
          })
       }
  }
  </code></pre>
  
  <p>Any ideas why it doesn't work and I don't receive the data?</p>