Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Tuesday, August 6, 2013

Windows Phone Application Development Event Life Cycle


Windows Phone Application Development Event  Life Cycle

It is important for development to know Application life Cycle so that they can understand well

Easy to understand using below image:

Step 1:

 

Step 2:



I believe now you are understanding well, we can discuss briefly about application life cycle below

Event and States together make up for an application life cycle .In windows phone application life cycle events (4 type of event)

Windows Application life cycle Events:

1.    Launching
2.    Deactivated
3.    Activated
4.    Closing

Windows mobile have 3 type of application state

1.    Running
2.    Dormant
3.    Tombstoned

Events lead to change the application state




1. Launch Event:

1. This event is raised when user launch the application
         è Mostly avoid this event for Application will get load quickly

Application Launching Event coding:( App.xaml.cs)

            // Code to execute when the application is launching (eg, from Start)
        // This code will not execute when the application is reactivated
        private void Application_Launching(object sender, LaunchingEventArgs e)
        {

        }

 1.1Running State:

            1. Once the application is launched its goes into Running state
            When Running State will appear?
1.    This state is on till the user doesn't navigate away from application
2.    The Phone is in Lock mode

 2. Deactivated Event:

          The user goes away from your application this event is raised
           In this application context and page should be saved
           When this application reactivated, that time save state should be restore

  Coding( App.xaml.cs)

  // Code to execute when the application is deactivated (sent to background)
        // This code will not execute when the application is closing
        private void Application_Deactivated(object sender, DeactivatedEventArgs e)
        {
        }

2.1        Dormant State:

-       Deactivated event goes into dormant state
-       In Dormant State the application is stopped ,but application in phone memory
-       Again application activate state that time phone need more memory,
(While activate application, that time state convert into Tombstoned state)

2.2        Tombstoned State:

-Once an application is terminated its goes into tombstoned state
-In this state the data and application state information preserved for maximum 5 application

3. Activated Event

When user switch back to a dormant or tombstoned application, this event is fired.
Developer should check the IsApplicationInstancePreserved property to know if the application is returning from being dormant or tombstoned state.
If it's value true, then the application was in dormant state else tombstoned state.


Coding: App.xaml.cs

        // Code to execute when the application is activated (brought to foreground)
        // This code will not execute when the application is first launched
        private void Application_Activated(object sender, ActivatedEventArgs e)
        {
            if (e.IsApplicationInstancePreserved == true)
            {
                //Dormant state
            }
            else
            {
                //tombstoned  state
            }

        }

4.Close Event

When the user navigates backwards from the first page of application, this event is fired.
Application gets terminated in this event and you get only 10 seconds to save any data if required.
For your Info : User does not have API for close application

Coding: App.xaml.cs

       // Code to execute when the application is closing (eg, user hit Back)
        // This code will not execute when the application is deactivated
        private void Application_Closing(object sender, ClosingEventArgs e)
        {
        }




Post a Comment