title: Android: How to detect if user exits activity
body: <p>I want to know when a user exits a certain activity, such as by:
  - Navigating to another activity within the same app
  - Exiting the app
  - Putting the phone to sleep</p>
  
  <p>What are ways to detect the above, and maybe other possibilities?</p>