title: How can lifecycle aware components using LifecycleObserver be aware of screen orientation changes
body: <p>Making a lifecycle aware component is super easy with <code>LifecycleObserver</code> e.g. pausing and stopping <code>MediaPlayer</code> when the user is leaving the screen. </p>
  
  <p>But is there any way for me to know if the lifecycle is going through <code>onPause</code>, <code>onStop</code> etc. just because a configuration change is happening? In that case, I wouldn't do anything to the <code>MediaPlayer</code>. In <code>Fragment</code> there is <code>activity?.isChangingConfiguration()</code> but in <code>LifecycleObserver</code> I don't get such information as far as I'm aware?</p>
  
  <pre><code>class AudioPlayerLifecycleObserver(private val mediaPlayer: MediaPlayer) : LifecycleObserver {
      @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE) 
      fun onPause() {
          // Media player will pause even if the screen is just changing orientation
          mediaPlayer.pause()
      }
  
      @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
      fun onStop() {
          // Media player will stop even if the screen is just changing orientation
          mediaPlayer.stop()
      }
  
  }
  </code></pre>
  
  <p>Media player stop and pause is used just for demonstrative purposes.</p>
  
  <p>Note that the architecture in mind is MVVM so passing a weak reference to fragment around is undesirable.</p>