Your SlideShare is downloading. ×
07 wp7   application lifecycle
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

07 wp7 application lifecycle

1,972

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
1,972
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

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

×