When a HoloLens 2 app is closed by the user it will go into a Suspended state as per the Documention, I would like to perform some actions such as checking the network connectivity when the app is Resumed.
How can this be handled or detected? is there an event that is triggered when the app is Resumed?
In a normal UWP I could do something like:
partial class MainPage
{
public MainPage()
{
InitializeComponent();
Application.Current.Resuming += new EventHandler<Object>(App_Resuming);
}
private void App_Resuming(Object sender, Object e)
{
// TODO: Do Something
}
}
Thanks,
As I couldn't get the Windows CoreApplication.Resuming method to work I have been looking at Unity methods as an alternative.
The one I found that did what I needed was OnApplicationFocus.
On the application being suspended OnApplicationFocus will have the focus parameter set to false. On the application being resumed the focus parameter will be set to true.
I dont beleive that this is triggered on first app load.
using UnityEngine;
public class Example : MonoBehaviour
{
private void OnApplicationFocus(bool focus)
{
}
}
Just to be clear my preference is the Windows method if there is a way to get it working.