title: Open the activity when device was locked
body: <p>i'm running an API in service class. When i get the particular response from that api i'm opening the AutoPlay activity. For calling the activity i wrote</p>
  
  <pre><code>Intent intent = new Intent(BackgroundService.this, AutoPlay.class);
  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  startActivity(intent);
  </code></pre>
  
  <p>and inside of onCreate in the AutoPlay activity i wrote the fallowing code to open the activity when device was locked</p>
  
  <pre><code>Window window = getWindow();
  window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
          | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
          | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
          | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
  </code></pre>
  
  <p>or</p>
  
  <pre><code>getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|
          WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|
          WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|
          WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
  </code></pre>
  
  <p>but above code was not opening the activity when device was locked. So, please any one help me to achive this</p>