Skip to Content

devsugar: Understanding iPhone 4 backgrounding


If you're looking for a simple and easy-to-follow introduction to iPhone 4's new backgrounding abilities, head on over to Oliver Drobnik's weblog and check out his latest write-up. You'll find a lovingly crafted graphic that walks you through the iPhone application lifecycle, showing how an application reacts to system changes like incoming phone calls or users' home button presses. A small portion of the chart appears at the top of this post.

Don't miss Drobnik's write-up in addition to his flowchart. I like the case he lays out for using applicationDidEnterBackground as the perfect place for saving state before giving up application control. As he points out, applicationWillTerminate will not get called in many application suspension cases.

Drobnik continues to refine his write-up, so keep checking back in for last-minute tuning and updates.

Categories

Developer

If you're looking for a simple and easy-to-follow introduction to iPhone 4's new backgrounding abilities, head on over to Oliver...
 

Add a Comment

*0 / 3000 Character Maximum Comment Moderation Enabled. Your comment will appear after it is cleared by an editor.

10 Comments

Filter by:
trav

I'm still confused at Steve saying "if you have a task manager, you're doing it wrong" in regards to multitasking, and yet here we have a task manager, and I find myself frequently going in and quitting apps to regain memory.

July 07 2010 at 4:41 AM Report abuse rate up rate down Reply
1 reply to trav's comment
Oliver Drobnik

It's not a real task manager. It's actually only a list of recent apps. Removing and app from the list does not regain you any memory with apps built for SDK < 4. Only IF it's suspended in background or running then the removal will also trigger a kill.

July 07 2010 at 5:07 AM Report abuse rate up rate down Reply
Jesse

On iOS 4, there's no need to save UI state upon the app being killed. Because, it doesn't really make sense if you want to continue a previous state after it's being killed.

By default the UI state doesn't change if the app is entering the background loop.

July 07 2010 at 12:28 AM Report abuse rate up rate down Reply
Michael Kaye

hmlong - if your app is being killed it is already suspended therefore not "running", so there is nothing it can respond to as such.

July 06 2010 at 4:44 PM Report abuse rate up rate down Reply
2 replies to Michael Kaye's comment
samsonsu

I agree. It's a common practice on mobile platform to directly kill a bg task without giving it any chance to run even one line of code. This ensures the OS can reclaim the resource in a timely manner.

Android works similarly. All activities are recommended to save state on onPause(). But there is one thing Android does better: it saves the view (activity) stack, and state of ui controls for you. On iPhone you'll have to do all these on your own. Not complicated but lots of boring work.

July 06 2010 at 5:29 PM Report abuse rate up rate down Reply
hmlong

It's already suspended, true. But it's still intact and in memory, thus there is in fact something to communicate with before completely killing it.

July 07 2010 at 3:01 AM Report abuse rate up rate down Reply
hmlong

Looks like Apple should add a method indicating that your application is being killed. Understand you're being killed due to low resources, but saving state on every applicationDidEnterBackground (switch) seems a bit wasteful.

July 06 2010 at 4:05 PM Report abuse rate up rate down Reply
3 replies to hmlong's comment
Buy an ad here

Tweets

© 2012 AOL Inc. All Rights Reserved.