unity-game-engineuwphololens

How can I know when the user hits home button on HoloLens 2 hand menu?


I am developing an XR app for the HoloLens2 and I need to know when the home button is pressed after opening the hand menu after pressing Windows button. Is there any way to get notified when home button was pressed or user wants to quit the application like that?


Solution

  • Recommend using the suspend events: https://learn.microsoft.com/en-us/windows/uwp/launch-resume/

    Example:

    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();
    }