Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent lockscreen in a Windows (Phone) 8.1 Universal App?

Do anyone know, how to prevent the lockscreen in a Windows (Phone) 8.1 Universal App?

In Windows Phone 8, I have used:

PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;

Has anyone an idea?

like image 997
Matt126 Avatar asked May 14 '14 11:05

Matt126


2 Answers

Code for copy-paste :)

Windows.System.Display.DisplayRequest KeepScreenOnRequest = new Windows.System.Display.DisplayRequest();

KeepScreenOnRequest.RequestActive();
like image 158
RelativeGames Avatar answered Jan 04 '23 00:01

RelativeGames


You may have a look at this question at MSDN, which points to this answer on SO. In short while using WinRT you can use DisplayRequest class:

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.

There is an example at MSDN, also remember to follow guidelines and release DisplayRequests when they are no longer needed.

like image 36
Romasz Avatar answered Jan 04 '23 00:01

Romasz