I would like to manage the behavior of my application when it closes (and not when it is suspended), but I couldn't find any method to override.
In this application, a user can log in with his profile: when he is in the main page of the application and presses back button, the app goes suspended and it's ok then that if it's resumed the user is still logged; what I want to do is that if the application is closed, the user won't be logged anymore, and if he opens the app again he has to log in again.
When the login is successful, I set local settings this way:
var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
localSettings.Values["Logged"] = true;
So I would like to set to "false" the value of logged whenever the application is closed (not suspended), but like I said I couldn't find any kind of "on close" method to override.
The only way I've found to achieve what I want is to set
var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
localSettings.Values["Logged"] = false;
in the "OnLaunched" method in App.xml.cs, but it's not working fine.
Define a handler vor the
Application.Suspending
event (https://msdn.microsoft.com/en-us/library/windows.ui.xaml.application.suspending).So there is no special event for closing the app.