Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Different states of activity in xamarin.android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 146
    Comment on it

    Hello All,

    In this blog we will discuss about the different states of the Activity of your application running on any device or the emulator.So the first one of the highest priority one is going to be the Active state or the running state which basically means that among all the application running on the device, your application will gets the highest priority and it is the application which user is currently actively using or looking at on his device, once something popups in front of it, typically a non full screen view or a notification,

    your activity goes into a Paused state, which means its still there and is not completely removed from memory but its goes into a kind of second in-charge, as if it is sitting back one layer bellow in the priority scale of your device.

    After that it moves into the Stopped or in the Background state which means that your application is still running and still consuming resources but its not visible on the screen so it means user has opened another application which is now in a active state and yours application has moved into background, so when your go into background or paused stated, its is likelihood that your application might be removed from the memory and stopped, But if user goes on to open your application and again that the application goes into a Restart state.

    So these are the 4 basic states of any application we talk about while working with an activity of your Android application.

    In order to deal with the different states of your application there are number of methods that can be overridden within the activity class, so you can take the appropriate activities for your application depending upon what's your application is doing and take advantage of all the cycles that application goes through.

    These methods are listed bellow :

            protected override void OnCreate(Bundle bundle)
            {
                // Always called when activity is created
                // Used to initialize variable and controls and Bind Views           
            }
    
            protected override void OnStart()
            {
                // Called when OnCreate is finished
                // Last chance to do any thing before user interaction
                // Refreshing data on the Views
            }
    
            protected override void OnResume()
            {
                // Called when OnStart is finished
                // User interaction begins here
                // Starting animations for user
                // Listening for GPS
                // Desplay alerts
            }
    
            protected override void OnPause()
            {
                // Called when activity is in paused state
                // Persist any impostant data
                // Release resource
                // prepare application for termination
            }
    
            protected override void OnStop()
            {
                // Called when activity is no longer visible to the user
            }
    
            protected override void OnDestroy()
            {
                // Called after OnStop method
                // Final method called before Activity is removed from the memory
                // Typically not used for much
            }
    
            protected override void OnRestart()
            {
                // Called when Activity is in Stopped/Backgrounded state
                // Activity can store ts state in bundle
            }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: