Windows Phone Application Lifecycle




Content "filtered", Please subscribe for FULL access.


Chapter 7 : Windows Phone App Lifecycle

Topics covered in this snack-sized chapter:



Windows Phone App Lifecycle: arrow_upward


  • Windows Phone execution model dictates that only a single application can be active at one time, the foreground application.
  • When user navigates away from any application Windows phone OS suspends your application for a limited time.
  • This eliminates the possibility of users getting their devices into a state where multiple applications are running in the background competing over the same limited resources.
  • PhoneApplicationService class provides four events to preserve and maintain app state: Launching, Activated, Running, Deactivated, and Closing.
  • Launching: When a new instance of your app is launched, the Launching event is raised.
  • private void Application_Launching
    (object sender, LaunchingEventArgs e)
    {
    }
    
  • Activated: The Activated event is raised when the application is reactivated (brought to foreground).
  • // This code will not execute when the application is first launched
     private void Application_Activated
    (object sender, ActivatedEventArgs e)
    {
    }
    
  • Running: App continues to run until the user navigates forward, away from the app, or backwards past the app’s first page.
  • Windows Phone apps shouldn’t provide a mechanism for the user to quit or exit.
  • Apps also leave the Running state when the phone’s lock screen engages unless you have disabled application idle detection.
  • Deactivated: The Deactivated event is raised when the user navigates forward, away from your app, by pressing the Start button or by launching another application.
  • // Code to execute when the application is deactivated (sent to background)
    private void Application_Deactivated(object sender, DeactivatedEventArgs e)
    {
    }
    
    • Closing:
    • The Closing event is raised when the user navigates backwards past the first page of an app.
    •  In this case, the app is terminated and no state is saved.
     private void Application_Closing
    (object sender, ClosingEventArgs e)
    {
    }
    
  • The Windows Phone application model provides a set of events and related APIs that allow your app to handle activation and deactivation in a way that provides a consistent and intuitive user experience.
  • Dormant: When the user navigates forward, away from an app, after the deactivated event is raised, the operating system will attempt to put the app into a dormant state.
  • Tombstoned: The device will maintain tombstoning information for up to five apps at a time.
  •  If an app is tombstoned and the user navigates back to the application, it will be relaunched and the application can use the preserved data to restore state.
  • OnNavigatedTo:The OnNavigatedTo() method is called when the user navigates to a page.
  • This includes when the app is first launched, when the user navigates between the pages of the app, and when the app is relaunched.
  • The OnNavigatedFrom:  The OnNavigatedFrom() method is called whenever the user navigates away from one page in your app.
  • This also happens as the result of normal page navigation within your application.


  • Thank You from Kimavi arrow_upward


  • Please email us at Admin@Kimavi.com and help us improve this tutorial.


  • Mark as Complete => Receive a Certificate in Windows-Phone-Programming

    Kimavi Logo

    Terms and conditions, privacy and cookie policy

    Kimavi @ YouTube | Email Admin @ Kimavi | Visit TheCodex.Me

    Beautiful Educational Videos for School, College, Languages & Encyclopedia


    Learn Python with 500,000 students


    Created with Love