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

what replaced PhoneApplicationService.Current.UserIdleDetectionMode in Windows 10 mobile


basically I want to stop the lockscreen from kicking in on a windows 10 app while my app is running on windows phone 7+ it was PhoneApplicationService.Current.UserIdleDetectionMode now I cant seem to find a replacement.


Solution

  • You should use the DisplayRequest class.

    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.

    Ref: DisplayRequest class

    Sample code:

    var dr = new DisplayRequest();
    dr.RequestActive();
    //  ...
    dr.RequestRelease();