Application<br />Lifecycle<br />Jason Lee<br />Ethos Technologies<br />
Agenda<br /><ul><li>Interruptions & User Expectations
Application Lifecycle
Tombstoning
Lifecycle Events
Resource Management
Play Time
Q & A</li></li></ul><li>Interruptions<br /><ul><li>Interruption comes from
A user action (i.e. press the start button)
An external event (an incoming phone call)
An internal action (i.e. taking a photo, choosing a contact)
Interruption characteristics
Interruptions are not predictable
Interruptions tend to happen frequently </li></li></ul><li>User Expectations<br /><ul><li>Phone and Applications
Phone is resource-constrained device, therefore we need to consume resources carefully
Phone is different from Desktop OS, which can hold multiple windows running processes simultaneously
However…
A user expects the application to be able to remain in the state where it was left
Microsoft development guideline requires application to provide such illusions that it keeps running continuously until it...
Upcoming SlideShare
Loading in …5
×

07 wp7 application lifecycle

2,034
-1

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,034
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

07 wp7 application lifecycle

  1. 1. Application<br />Lifecycle<br />Jason Lee<br />Ethos Technologies<br />
  2. 2. Agenda<br /><ul><li>Interruptions & User Expectations
  3. 3. Application Lifecycle
  4. 4. Tombstoning
  5. 5. Lifecycle Events
  6. 6. Resource Management
  7. 7. Play Time
  8. 8. Q & A</li></li></ul><li>Interruptions<br /><ul><li>Interruption comes from
  9. 9. A user action (i.e. press the start button)
  10. 10. An external event (an incoming phone call)
  11. 11. An internal action (i.e. taking a photo, choosing a contact)
  12. 12. Interruption characteristics
  13. 13. Interruptions are not predictable
  14. 14. Interruptions tend to happen frequently </li></li></ul><li>User Expectations<br /><ul><li>Phone and Applications
  15. 15. Phone is resource-constrained device, therefore we need to consume resources carefully
  16. 16. Phone is different from Desktop OS, which can hold multiple windows running processes simultaneously
  17. 17. However…
  18. 18. A user expects the application to be able to remain in the state where it was left
  19. 19. Microsoft development guideline requires application to provide such illusions that it keeps running continuously until it is get killed</li></li></ul><li>Application Lifecycle<br />Running<br />Dormant<br />Tombstoned<br />Deactivated<br />Deactivated<br />Dead, and no longer <br />lives in memory.<br />But with something<br />carved on a Tombstone<br />Phone resources detached<br />Threads & Timers suspended<br />But app instance remains in memory<br />Activated<br />e.Preserved == true<br />Fast App Resume<br />Activated<br />e.Preserved == false<br />You Will See Resuming Process Bar<br />
  20. 20. Tombstoning<br /><ul><li>When an app is tombstoned, it means
  21. 21. The app is dead
  22. 22. Some relevant data is saved by System for the app/page, which is called State information
  23. 23. When user navigates back
  24. 24. System restarts the application, passes applications state back to the App
  25. 25. System navigates to the very page where it was left, passes page state back to the Page
  26. 26. Developers should
  27. 27. Write code to save state before the app gets tombstoned
  28. 28. Write code to restore state after the app is reactivated from tombstoned</li></li></ul><li>Lifecycle Events - App<br /><ul><li>Application_Launching
  29. 29. Fired when the application is started
  30. 30. Not fired when the application is reactivated
  31. 31. Load app settings/configuration
  32. 32. Application_Activated
  33. 33. Fired when the application is reactivated (brought to foreground)
  34. 34. Not fired when the application is started
  35. 35. Restore app state if tombstoned
  36. 36. Application_Deactivated
  37. 37. Fired when the application is deactivated (sent to background)
  38. 38. Not fired when the application is closed
  39. 39. Save app state as needed
  40. 40. Application_Closing
  41. 41. Fired when the application is closing (i.e. user presses Back key)
  42. 42. Not fired when the application is deactivated
  43. 43. Save app settings/configuration</li></li></ul><li>Lifecycle Events - Page<br /><ul><li>OnNavigatedTo
  44. 44. Fired when the application is started
  45. 45. Not fired when the application is reactivated
  46. 46. Restore page state if tombstoned
  47. 47. OnNavigatedFrom
  48. 48. Fired when the application is deactivated (sent to background)
  49. 49. Not fired when the application is deactivated
  50. 50. Save page state as needed</li></li></ul><li>Code Sample - 1<br /><ul><li>Application_Launching
  51. 51. Load app settings/configuration</li></li></ul><li>Code Sample - 2<br /><ul><li>Application_Closing
  52. 52. You have only 10 seconds to finish all job
  53. 53. If you’ve got complex data to save, it’s recommended to save your data while the app is running at appropriate points</li></li></ul><li>Code Sample - 3<br /><ul><li>Application_Deactivated
  54. 54. Save app state as needed</li></li></ul><li>Code Sample - 4<br /><ul><li>Application_Activated
  55. 55. Restore app state if tombstoned</li></li></ul><li>Time Limits<br />
  56. 56. Resource Management - 1<br />Deactivating App<br />Page.<br />OnNavigatedFrom<br />- You may release phone resources, but not necessarily, the framework is doing it anyway<br />- You MUST Save app/page state<br />App.<br />Deactivated<br />Framework:<br />Detach Resources<br />Framework:<br />Suspend Timers and Threads<br />Dormant App<br />
  57. 57. Resource Management - 2<br />Running App<br />Page.<br />OnNavigatedTo<br /><ul><li>MediaElement : Reset Source/Position
  58. 58. Socket : Reconnect
  59. 59. Camera: Recreate Object
  60. 60. Restore app state if tombstoned</li></ul>App.<br />Activated<br />Framework:<br />Attach Resources<br />Framework:<br />Resume Timers and Threads<br />Dormant App<br />
  61. 61. Take It Serious<br /><ul><li>It is required, not just recommended !
  62. 62. Microsoft tries its best to keep apps in the line, providing consistent user experience to end users.
  63. 63. It is about money !
  64. 64. If your app does not handle lifecycle issues, then it will be disqualified to be published on marketplace.</li></li></ul><li>Play Time !<br /><ul><li>Goals
  65. 65. To understand various lifecycle events and orders of occurring under different situations
  66. 66. To be able to store and retrieve state information
  67. 67. To understand how tombstoning works</li></li></ul><li>Tip<br /><ul><li>To test tombstoning on emulator</li></li></ul><li>! & ?<br />Thank You ! <br />Any Questions ?<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×