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

假如想象 提交于 2020-01-22 14:20:09

问题


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?


回答1:


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.




回答2:


Code for copy-paste :)

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

KeepScreenOnRequest.RequestActive();


来源:https://stackoverflow.com/questions/23653968/how-to-prevent-lockscreen-in-a-windows-phone-8-1-universal-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!