title: Android: How do I know if Activity.onStop() is being called because the user is going back to Home?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1843911/android-detect-when-another-activity-is-launched-or-your-activity-loses-focus">Android: Detect when another Activity is launched (or your activity loses focus)</a>  </p>
  </blockquote>
  
  
  
  <p>I need be able to tell if Activity.onStop() was called because my application is moving to a new activity, or if it was closed because the user pressed the "Home" key or hit the back button from the bottom of the activity stack.</p>
  
  <p>The reason is because I need to know when it is appropriate to shut off music that is playing in my application (A game). There is nothing more annoying than hitting home and having something playing music in the background.</p>
  
  <p>However, Activity.OnStop() is called for each activity change, and I don't want to suspend music when moving between multiple activities in my app. I just can't find a way to differentiate between going home and going to a internal activity.</p>
  
  <p>Am I perhaps hooking into the wrong events?</p>
  
  <p>Any advice?</p>