title: How to get broadcast for screen lock in android
body: <p>How to get trigger that screen is locked or on in android??</p>
  <p>i tried using SCREEN_OFF &amp; SCREEN_ON action in broadcast receiver but it's not working.</p>
  <pre class="lang-java prettyprint-override"><code>public void onReceive(Context context, Intent intent) {
      Log.d(&quot;XYZ&quot;, &quot;Screen ON/OFF&quot;);
  
      Toast.makeText(context, &quot;screen&quot;,10000).show();
      if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
          .......
      }
  }
  </code></pre>
  <p>in activity i have registered broadcast like-</p>
  <p>screen is object of my broadcast receiver</p>
  <pre class="lang-java prettyprint-override"><code>IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
  filter.addAction(Intent.ACTION_SCREEN_OFF);
  mContext.registerReceiver(screen, filter);
  </code></pre>