Background Execution and Multitasking
In iOS 4 and later, multitasking allows apps to continue running in the background even after the user switches to another app while still preserving battery life as much as possible. Most apps are moved to the suspended state shortly after entering the background. Only apps that provide important services to the user are allowed to continue running for any amount of time.
As much as possible, you are encouraged to avoid executing in the background and let your app be suspended. If you find you need to perform background tasks, here are some guidelines for when that is appropriate:
-
You need to implement at least one of several specific user services.
-
You need to perform a single finite-length task.
-
You need to use notifications to alert the user to some relevant piece of information when your app is not running.
The system keeps suspended apps in memory for as long as possible, removing them only when the amount of free memory gets low. Remaining in memory means that subsequent launches of your app are much faster. At the same time, being suspended means your app does not drain the device’s battery as fast.
参考:
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW20
在iOS 4及以后版本中,多任务功能允许应用程序在用户切换到其他应用的同时继续运行在后台,同时尽可能地保持电池寿命。大多数应用在进入后台状态后不久就会被暂停。只有为用户提供重要服务的应用才允许长时间运行。本文提供了在适当情况下执行后台任务的指导原则。
99

被折叠的 条评论
为什么被折叠?



