Now you may be wondering how the Mango Life Cycle affect our lives as developers, well the applications we build need to take that model into account. We need to anticipate that is a common for a user to hop over to another application using the start or to hit the search button for example. Also there are also common mechanism that will trigger deactivation in our application.
For example, the phone receives an incoming phone call or the user may open a launcher or chooser. Just like the people who build the platform, as developers our objective is to make the user experience SEAMLESS as a result, when the application getes deactivated we need to save our application specific data and we restore it if and when the application is reactivated. There are two types of state that we need to manage in our application, page state and application state.
Page state is a visual state of the page and its UI elements. In mango, we save and store page state in the same way with windows phone 7.
PhoneApplicationPage.OnNavigatedTo - called before page displays
PhoneApplicationPage.OnNavigatedFrom - called before page is left.
When OnNavigatedTo is called the application may be coming from a close state if the application is just launched and this is the first page. A page earlier in the history stack(Previous Page), a page later in the history stack (Next page), A dormant state if the application is being reactivated or a tombstoned application also if the application is being reactivated. The OnNavigationFrom on the other hand may be called when the user navigates forward to another page, the user navigates back to the previous page by pressing the back button.
The application is going in a dormant mode, for example the user press the start button the application is going into a close state if the user press the back button and this page is the first page of our application. So as you can see, there are many scenarios to consider when deciding when to save and when to restore page state.