title: How to check whether my app has lost focus?
body: <p>I am new to coding and I was wondering, if there is a way to check when app loses focus(goes from foreground to background).</p>
  
  <p>Is there anything like <code>onLosefocuslistener</code>?</p>
  
  <p>To clarify I don't want when activity loses focus. I want when the whole app goes in background either cause user pressed the 'home' button or another app went in foreground.</p>