Android - Turn off display without triggering sleep/lock screen - Turn on with Touchscreen

Posted by NebulaSleuth on Stack Overflow See other posts from Stack Overflow or by NebulaSleuth
Published on 2012-03-02T18:16:32Z Indexed on 2012/11/07 5:00 UTC
Read the original article Hit count: 154

Filed under:
|

I have been trying to find a way to turn off the display, and wake up from the user touching the touch screen.
The device is in an embedded environment where the device is a tablet and the user does not have access to anything except the touch screen (no buttons at all).

It is connected to power so the battery won't be a problem, but when I detect no activity I want to turn off the screen so it isn't staring them in the face all day and doesn't reduce the life the LCD backlight.

I maintain a wakelock permanently and decide when to sleep myself.

The problem is that when I turn off the screen using :

WindowManager.LayoutParams params = getWindow().getAttributes();
params.screenBrightness = 0;
getWindow().setAttributes(params);

The activity gets paused and stopped. And the unit does not respond to a touch to wake it up. You need to press the power button. At that point the "slide to unlock" shows up.

I want to turn off the display, and then stay running so I can detect a touch screen event and turn the display back on.

I also tried turning the display to a brightness of 0.1, which works on some devices, but the device I need it to work on, only "dims" the display.

I also tried this:

// First Remove my FULL wakelock

//then aquire a partial wake lock (which should turn off the display)
PowerManager.WakeLock wl = manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Your Tag");

wl.acquire();

however this method does not turn off the display.

© Stack Overflow or respective owner

Related posts about android

Related posts about wakelock