title: Wake up device programmatically
body: <p>I want to wake up and unlock a device. Then, I'd like show an activity when the user has new message from <code>Firebase</code>. </p>
  
  <p>I wrote this on <code>onResume()</code> method:</p>
  
  <pre><code>window = this.getWindow();
  window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
  window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
  </code></pre>
  
  <p>This works for devices with API > 19. The problem is that in <code>KitKat</code>, it either does nothing or it wakes up the screen but doesn't unlock the device.</p>
  
  <p>Also I set the right permissions in the <code>AndroidManifest.xml</code>:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
  &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  &lt;uses-permission android:name="android.permission.DISABLE_KEYGUARD" /&gt;
  </code></pre>
  
  <p>Also in <code>MyFirebaseMessagingService.class</code>, I'm starting an activity with <code>FLAG_ACTIVITY_NEW_TASK</code> as flag.</p>
  
  <p>Does anyone know what am I missing?</p>
  
  <p>Thanks for the help.</p>