Detect if Application was suspended in OnNavigatedFrom for Windows Phone 8

299 views Asked by At

Is there anyway to know in the OnNavigatedFrom if the App is navigating from this page because it is being suspended? I have event handlers that update the UI, that I dont want them unsubscribed from if I am just suspending the App

1

There are 1 answers

0
MattyMerrix On BEST ANSWER

Thanks to @Romasz and his answer to my comment I was able to figure out you can use this. Which works great!

protected override void OnNavigationFromPage(System.Windows.Navigation.NavigationEventArgs e)
{
    if (e.Uri.ToString() != "app://external/") 
    {
        //App being suspended.
    }
    else
    { 
        UnSubscribeFromEvents(); 
    }
}

As you see the NavigationEventArgs Uri property is set to "app://external/" when you are being suspended, any other time it contains a full uri string of the page you are going too! This is just what I was looking for.

You can see the original post here.

Detecting deactivation and app close in Windows Phone 8.1 XAML