title: How to force the device to return in standby mode
body: <p>I have an alarm which periodically (every 30 sec) wakes up my device. When the alarms starts, I use the following code to open a window:</p>
  
  <pre><code>private void CreatePreviewDialog()
  {               
      dummy_frame_layout = new DummyFrameLayout(context);
  
      wm_params = new WindowManager.LayoutParams(
              240, 320, 0, 0,
              WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,                
              // WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|
              WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|
              WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|
              WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON|                
              WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
              WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
              PixelFormat.TRANSLUCENT);
  
      wm_params.gravity = Gravity.CENTER;
      wm_params.setTitle("Preview");
  
      window_manager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
      window_manager.addView(dummy_frame_layout, wm_params);
  }
  </code></pre>
  
  <p>Then, I close the window with the following code:</p>
  
  <pre><code>private void DestroyPreviewDialog()
  {
      ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).removeView(dummy_frame_layout);
      dummy_frame_layout = null;
  }
  </code></pre>
  
  <p>The problem is as follows. Suppose that the device is in standby mode. When the alarm happens it calls <code>CreatePreviewDialog</code> that turns on the display. When the <code>DestroyPreviewDialog</code> is called, I would like that the device returns in its standby mode or, at least, that the display turns off but I have not found any solution to this problem. I've also added the following code before closing the window in <code>DestroyPreviewDialog</code>:</p>
  
  <pre><code>    wm_params.screenBrightness = 0.0f;
      window_manager.updateViewLayout(dummy_frame_layout, wm_params);
  </code></pre>
  
  <p>but nothing happens. The screen remains on showing the lockscreen till the next alarm happens. Just like if the application is in foreground. Any idea? </p>