title: Start Activity screen even if screen is locked in Android
body: <p>How to start an Activity on device even if screen is locked. I tried as below but it's not working.</p>
  
  <p>Broadcast receiver:</p>
  
  <pre><code>Intent alarmIntent = new Intent("android.intent.action.MAIN");
          alarmIntent.setClass(context, Alarm.class);
          alarmIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          alarmIntent.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED +
                               WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD +
                               WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON +
                               WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
          context.startActivity(alarmIntent);
  </code></pre>