Prevent tablet from sleeping while app is running

2019-05-01 16:22发布

问题:

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.

回答1:

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.



回答2:

Go to your screen saver in personalization settings. Select none.