Changing contacts access in settings terminates UWP application.
How to get terminating or terminated event when application is closed by the system?
Changing contacts access in settings terminates UWP application.
How to get terminating or terminated event when application is closed by the system?
Changing contacts access in settings terminates UWP application.
@Peter Torr - MSFT was correct. This behavior is by design. When you change the privacy settings, it's just forced to restart with the new privacy settings. But currently UWP apps could not do the restart by the controller outside the app container, so it has been terminated.
But in that case application should be notified or must be restarted.
You could submit a 'Feature Request' on WPDev UserVoice.
Subscribe UnhandledException and Suspending event in constructor of App class in App.xaml.cs file
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
this.UnhandledException += App_UnhandledException;
}
Whenever an exception occur in application this event trigger
private async void App_UnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e)
{
// do your job
e.Handled = true;
}
You also can set Handled property of exception true in order to prevent your application crash and close in a bad way.
Whenever your application execution is being suspended, this event triggered
/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private async void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity
deferral.Complete();
}