开发者

Do background applications *ever* quit in iOS 4?

I don't fully understand Apple's iOS 4 model, I've been poring through documentation for hours, but I still appreciate some help.

Do backgrounded iPhone apps ever quit? For example, when I close a location-tracking app such as Loopt, it will be backgrounded but will it subscribe to the OS's significant locations service? According to apple (if I understand it co开发者_开发技巧rrectly), even it's suspended or closed, it will be notified of my current location. Does that mean, in effect, that it will always be aware of my location, as long as it's on my phone? Or until I restart my phone?

Thanks,

  • rob


Applications have to be specifically written to take advantage of the multitasking features. They don't just get it for free.

When the user "quits" an app by pressing the home screen, if it is fast-switching aware, it will be suspended. It's state is saved and it is sent to the background but it does not run.

If an app is written so that it takes advantage of background processing for location, voip or audio, then only certain aspects will continue to run in the backround. Eg. if a voip app is suspended, it will tell the OS that it wants to keep it's network sockets alive and to be notified if an incoming call arrives on those sockets. When this happens, the app is 'woken up' and takes back control of the sockets from the OS and resumes play normally.

In the case where a call is already in progress, and the user closes the app, again the app tells the OS to keep the sockets alive and to keep processing audio but the rest of the app (the UI, any other features) are suspended and don't run.

Apps on iOS4 will quit if they're not compiled against the 4.0 SDK (therefore not being multitasking aware) or if the UIApplicationExitsOnSuspend key is specified and set to true in the app's info.plist file.

Apps are killed on demand by the OS if the system begins to run low on resources.

Finally, a user may kill an app by double tapping the home button, pressing and holding one of the suspended app icons and then pressing the "close" button that appears on their corner.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜