title: Android, how do I know user is switching to another app
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5593115/run-code-when-android-app-is-closed-sent-to-background">Run code when Android app is closed/sent to background</a>  </p>
  </blockquote>
  
  
  
  <p>In my android app I need to be notified when users switching from my app to any other app, in order to do some security jobs. It can be by tapping on Back, Home button, through Recent Apps button. Any other ways?
  Couldn't find anything in android.app.Application.
  I have many activities in the app, to put code in Activity.onPause() won't work because it may goes to another activity in the same app. I need to find a way to be noticed.
  Any good idea on this?
  Thanks</p>