w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to set screen time out for an activity then turn back on when screen pressed

I can already tell you that detecting touch events when the screen is off is not possible. There is a "workaround" of using the accelerometer to detect movement if the touch produces just enough movement to be detectable.

To programmatically turn the screen on/off:

PowerManager powermanager = ((PowerManager)
context.getSystemService(Context.POWER_SERVICE));
wakeLock = powermanager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK |
PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag");
wakeLock.acquire();

...

if(wakeLock.isHeld()) {
    wakeLock.release();
}




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.