title: When does the *Window focus* change in Android?
body: <p>In my project, I need to catch the Window focus change. I have logged out the results for all the stages of an activity. When the screen is on, the result is as follows:</p>
  
  <pre><code>02-17 13:50:03.898: DEBUG/InquiryInterface(3829): onCreate screen state : false
  02-17 13:50:03.898: DEBUG/InquiryInterface(3829): onStart screen state : false
  02-17 13:50:03.898: DEBUG/InquiryInterface(3829): onResume screen state : false
  02-17 13:50:08.998: DEBUG/InquiryInterface(3829): onPause screen state : true
  02-17 13:50:09.178: DEBUG/InquiryInterface(3829): onWindowFocusChanged : false
  02-17 13:50:09.228: DEBUG/InquiryInterface(3829): onStop screen state : false
  02-17 13:50:09.228: DEBUG/InquiryInterface(3829): onDestroy screen state : false
  </code></pre>
  
  <p>onWindowFocusChanged is the method provided by the class Activity. And the value shown in the list is the input value(boolean hasFocus) of the method onWindowFocusChanged.</p>
  
  <p>I have used the following code to get the state of window focus for every state of the method, onCreate, onStart, etc.</p>
  
  <pre><code>@Override
      public void onResume() {
          super.onResume();
          Log.d(TAG, "onCreate screen state : "
                   +String.valueOf(this.hasWindowFocus()));
  }
  </code></pre>
  
  <p>But in the Android documention, I read : the method onResume() is <strong>Called when the activity will start interacting with the user. At this point your activity is at the top of the activity stack, with user input going to it.</strong> </p>
  
  <p>So in this way, I should get "True" for the window focus within onResume, but not in onPause(). Anyone has an idea why this happens?</p>