有没有办法检测Windows手机屏幕何时关闭?当这种情况发生时,可以使应用程序运行吗?
答案 0 :(得分:4)
您应该将ApplicationIdleDecectionMode
设置为Enabled
并处理根框架的Obscured
和Unobscured
事件:
Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Enabled;
var rootFrame = App.Current.RootVisual as PhoneApplicationFrame;
if(rootFrame != null)
{
rootFrame.Obscured += new EventHandler<ObscuredEventArgs>(rootFrame_Obscured);
rootFrame.Unobscured += new EventHandler(rootFrame_Unobscured);
}
详细了解article