title: Programmatically turn screen on in android
body: <p>I am developing an alarm application. From the main activity i set the alarm using broadcast. Then in onReceive in broadcast receiver i call activity that is enabling user to shut down or snooze the alarm...In that activity, in the beginning of onCreate i use this lines to turn screen on and unlock the device:</p>
  
  <pre><code>final Window win = getWindow();
      win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                    | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); 
      win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                    | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
  </code></pre>
  
  <p>This works perfect on Samsung Galaxy S2 with android 2.3.4 but doesnt work on htc with android 2.3.5. On htc it does nothing, and when i press lock button screen automatically unlocks without me draging the circle. Its like flag_dissmiss_keygard is working but flag_turn_screen_on isnt. Is there another way or another solution for doing this?</p>