title: get onPause reason android
body: <p>Is there any way to get the <strong>onPause()</strong> reason or the event that execute make the activity in pause ?</p>
  
  <p>Example</p>
  
  <pre><code>@Override
  public void onPause() {
  
      Log.d(TAG, "&gt;&gt; onPause()");
  
      if(onPauseReason() == SCREEN_OFF)
      {
         //Do something
      }
      super.onPause();
      Log.d(TAG, "&lt;&lt; onPause()");
  }               
  </code></pre>
  
  <p><strong>onPauseReason()</strong> is the function that gives the reason of the onPause.</p>