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
    • 185
    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 :

    1. protected override void OnCreate(Bundle bundle)
    2. {
    3. // Always called when activity is created
    4. // Used to initialize variable and controls and Bind Views
    5. }
    6.  
    7. protected override void OnStart()
    8. {
    9. // Called when OnCreate is finished
    10. // Last chance to do any thing before user interaction
    11. // Refreshing data on the Views
    12. }
    13.  
    14. protected override void OnResume()
    15. {
    16. // Called when OnStart is finished
    17. // User interaction begins here
    18. // Starting animations for user
    19. // Listening for GPS
    20. // Desplay alerts
    21. }
    22.  
    23. protected override void OnPause()
    24. {
    25. // Called when activity is in paused state
    26. // Persist any impostant data
    27. // Release resource
    28. // prepare application for termination
    29. }
    30.  
    31. protected override void OnStop()
    32. {
    33. // Called when activity is no longer visible to the user
    34. }
    35.  
    36. protected override void OnDestroy()
    37. {
    38. // Called after OnStop method
    39. // Final method called before Activity is removed from the memory
    40. // Typically not used for much
    41. }
    42.  
    43. protected override void OnRestart()
    44. {
    45. // Called when Activity is in Stopped/Backgrounded state
    46. // Activity can store ts state in bundle
    47. }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: