title: How to check screen on or off event of android only user behavior
body: <p>I want to show some screen on the lock screen when the screen is turned on. So I wrote the following code.</p>
  
  <pre><code>public class BroadcastReceiverScreen extends BroadcastReceiver {
  @Override
  public void onReceive(Context context, Intent intent) {
      if (intent.getAction() != null &amp;&amp; 
         Intent.ACTION_SCREEN_ON.equals(intent.getAction())) {
  
      } else if (intent.getAction() != null &amp;&amp; 
        Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
      }
  }
  </code></pre>
  
  <p>However, when the user does not turn on the screen with the power button, the <strong>alarm clock, message, etc are automatically displayed</strong> when the screen is turned on.</p>
  
  <p><strong>I want to make it work only when the user turns on the screen.</strong></p>
  
  <p>For example, when the phone rings, you can detect and avoid the following code.</p>
  
  <pre><code>    PhoneStateListener phoneStateListener = new PhoneStateListener() {
          public void onCallStateChanged(int state, String incomingNumber) {
              if (state == TelephonyManager.CALL_STATE_IDLE) {
                  isPhoneIdle = true;
                  //Log.e("PhoneCallState", "STATE_IDLE");
              } else if (state == TelephonyManager.CALL_STATE_RINGING) {
                  isPhoneIdle = false;
                  //Log.e("PhoneCallState", "STATE_RINGING : Incoming number " 
                 + incomingNumber);
              } else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
                  //Log.e("PhoneCallState", "STATE_OFFHOOK");
                  isPhoneIdle = false;
              }
          }
      };
  </code></pre>
  
  <p><strong>In conclusion, can the user detect it only when the screen is turned on?
  Not automatically turned on screen.</strong></p>
  
  <p>Thank you.</p>