我正在为 HoloLens2 开发 XR 应用程序,我需要知道在按 Windows 按钮后打开手动菜单后何时按下主页按钮。当按下主页按钮或用户想要像这样退出应用程序时,有什么方法可以收到通知吗?
建议使用挂起事件:https://learn.microsoft.com/en-us/windows/uwp/launch-resume/
示例:
Application.Current.Suspending += OnSuspending;
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
// Save application state and stop any background activity
deferral.Complete();
}