Detect deactivation and application closure in Windows Phone 8.1 XAML

For security reasons, I need to log out when I exit the application and display the login screen when I return.

In Windows Phone 8 and Windows Phone 8.1 Silverlight, there are Application_Deactivated and Application_Closing methods of the App class (or OnClose, OnDeactivate methods for overriding in Caliburn.Micro).

The only interesting events are Suspend and Resume , but they are not called when you exit the application using the "Start" button and are returned using the "Back" button or launching the application from the list.

What are the alternatives for Windows Phone 8.1 XAML?

(Setting ActivationPolicy="Replace" will solve half the problem, but I think this is not possible when WMAppManifest.xml is not an event in the Windows Phone 8.1 XAML project).

+8
c # xaml windows-phone-8
source share
1 answer

The suspension event will be raised immediately after the transition from the application, but not in debug mode. I created a simple application in which modyfing LocalSettings when the event is paused, and then receives information when it resumes.

You probably know, but for the sake of completeness of the answer - some remarks:

  • before the Suspending event, the OnNavigatedFrom event is fired, but when you resume, OnNavigatedTo is called a non - reference :

    Note. On Windows Phone, OnNavigatedFrom () is called when the application is paused. OnNavigatedTo () is not called when the application resumes.

  • to check pause / resume using the debugger, use Lifecycle events on the Debug tab - more

  • link to the Application Lifecycle in Windows Runtime Applications

+15
source share

All Articles