title: How to detect whenever app comes to foreground in android
body: <p>I have read alot about <code>how to detect when app comes to foreground</code> but unable to find any satisfactory answer. Most of them are using onResume() and onClose() methods and keeping count etc</p>
  
  <blockquote>
    <p>I am working on a crypto-currency app and I have to ask for passCode
    whenever app comes to foreground, which is very critical in my case.
    It must ask for passCode every time.</p>
  </blockquote>
  
  <p>So that is why I want to assure that isn't there any method to detect this in android by default if not then what is the best approach?</p>