Search code examples
c#uwpwindows-10-mobilewindows-10-universal

C# uwp application prevent idle mode


Windows Phone 8 had the ability for your app to prevent the phone from going to the lock screen: PhoneApplicationService.Current.ApplicationIdleMode = IdleDetectionMode.Disabled ;

Anybody know what the equivalent is for Universal Window Platform?


Solution

  • You can use this:

    var displayRequest = new Windows.System.Display.DisplayRequest();
    displayRequest.RequestActive();
    

    But be aware of the fact that you are just requesting the screen to stay active. This can not prevent the user from locking the screen by himself manually.