title: Android - Turn off screen without going in StandBy Mode
body: <p>I know that this question has been asked a lot of times but it has never been answered satisfactorily.</p>
  
  <p>My problem is the following:</p>
  
  <p>I have an activity which prevents the screen from turning off for a predefined amount of time.</p>
  
  <pre><code>getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  </code></pre>
  
  <p>When the predefined time is over I show a dialog with a countdown to inform the user that the display will turn off in 10 seconds if he doesnt press "cancel".</p>
  
  <p>I managed to turn off the display but the phone always switches into StandBy-Mode.</p>
  
  <p>For switching off I used:</p>
  
  <pre><code>Window mywindow = getWindow();
  
  WindowManager.LayoutParams lp = mywindow.getAttributes();
  
  lp.screenBrightness = 0.0f;
  
  mywindow.setAttributes(lp);
  </code></pre>
  
  <p>Is there any possibility to completely darken the display without going to StandBy-Mode (which pauses the activity).</p>
  
  <p>My goal is that the user should be able to just tap the display to brighten up the screen again. So the activity has to remain in an active state.</p>
  
  <p>A similar question has been asked <a href="https://stackoverflow.com/questions/9538331/android-turn-off-display-without-triggering-sleep-lock-screen-turn-on-with-t">here</a>. </p>
  
  <p>Since this question is almost a year old I am hoping that maybe somebody managed to this in the mean time.</p>
  
  <p>Lots of greetings</p>
  
  <p>Siggy</p>