title: Message when Android App is closed
body: <p>I am porting an iOS App to Android, and am having a little difficulty with the terminally.
  I want the App to sync when starting/coming to the foreground (i.e. the user selects the App) and when the App goes to the background (e.g. when going to the main screen and start using another App.)</p>
  
  <p>Is there an easy way to do that in Android?
  I added onResume() and onPause() to my Activities, but this will be triggered when the activity resumes or pauses, not when the App as a whole pauses (and results in a lot of sync each time the user does something).</p>
  
  <p>Update:
  The Sync operation is a Service which is called when the App needs to get new/updated information from the server. As such, this needs to be done when the Application is started/resumed by the suer (after inactivity for some time) and it needs to do this when the user actively stops using the Application.</p>