Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent tablet from sleeping while app is running

I'm trying to write a Windows 8 tablet app that often can go multiple minutes between receiving input.

The problem is, that if i don't keep touching the screen, the power saver will activate, and the screen will automatically go black, and it disrupts the user of the app.

Is there a way that my app can prevent the power saver from activating, or at least extend the time it takes for the power saver to activate.

like image 954
Sam I am says Reinstate Monica Avatar asked Nov 13 '22 18:11

Sam I am says Reinstate Monica


1 Answers

You should use DisplayRequest class to keep screen from turning off.

Apps that show video or run for extended periods without user input can request that the display remain on by calling DisplayRequest::RequestActive. When a display request is activated, the device's display remains on while the app is visible. When the user moves the app out of the foreground, the system deactivates the app's display requests and reactivates them when the app returns to the foreground.

like image 181
Denis Avatar answered Nov 15 '22 09:11

Denis