检测 Windows Phone 中的屏幕何时关闭 [英] detect when screen turns off in windows phone
本文介绍了检测 Windows Phone 中的屏幕何时关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么办法可以检测到 Windows Phone 的屏幕何时关闭?发生这种情况时可以使应用程序运行吗?
Is there any way to detect when the screen turns off in the windows phone? It is possible to make the application run when this happens?
推荐答案
您应该将 ApplicationIdleDecectionMode
设置为 Enabled
并处理 Obscured
和 >Unobscured
根框架事件:
You should set ApplicationIdleDecectionMode
to Enabled
and handle Obscured
and Unobscured
events of root frame:
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);
}
看看这个文章
这篇关于检测 Windows Phone 中的屏幕何时关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文