Search code examples
windows-10windows-10-mobilewindows-10-universal

prevent windows 10 mobile from locking


I have finally upgraded my windows 8 app to windows 10 app. Unfortunately some of the features are not working in windows 10. One of the features I am looking is preventing automatic lock screen while my application is running.

In windows phone 8 I am using below code to prevent auto locking of windows phone, however, in windows 10, I didn't find this feature.

PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;

What is the alternate of the above in windows 10?

Thanks!


Solution

  • you might use the new DisplayRequest class

    Pretty simple to use :

    displayRequest = new DisplayRequest();
    displayRequest.RequestActive();
    //Do your always on stuff
    displayRequest.RequestRelease();