PDA

View Full Version : Do phone calls kill apps?




milktooth
Nov 2, 2009, 07:31 PM
No. People do.



I only have an iPod touch and don't have access to an iPhone. I'm writing a countdown timer app but have concerns that incoming calls would interrupt its function.

What happens when phone calls are received or made? Are apps left running in the background?

Would an [NSTimer scheduledTimerWithTimeInterval...] be interrupted?



GoCubsGo
Nov 2, 2009, 07:32 PM
No apps run in the background of a non-jailbroken iPhone.

milktooth
Nov 11, 2009, 03:59 PM
From Apple:

Even if your application is not designed to use iPhone-specific features like the camera, GPS, or Compass, when it runs on an iPhone it can encounter a number of unique situations. For instance, if a user accepts an incoming phone call while using your application, your application will quit. It must be prepared to handle this behavior. The right thing is to restore the user's state when they relaunch the application.

xsmasher
Nov 11, 2009, 06:15 PM
I only have an iPod touch and don't have access to an iPhone. I'm writing a countdown timer app but have concerns that incoming calls would interrupt its function.

What happens when phone calls are received or made? Are apps left running in the background?

You can use the timer in the "clock" app to simulate an interruption. If the user gets a call you get applicationWillResignActive, if they decline the call you get applicationDidBecomeActive, and if they take the call your app gets terminated.

To simulate this, set a clock alarm for one minute and start your app. When the alarm window appears, you can click "ok" to simulate ignoring the call, or click the home button to simulate taking the call.

mkrishnan
Nov 11, 2009, 06:22 PM
Sorry for butting in, I'm not a programmer, but I wondered... how is it that there were some programs in the past that could stay in a locked/paused state when a call came in? Gameloft's Ferrari GT -- this is an older game now -- could definitely do this.

xsmasher
Nov 11, 2009, 06:55 PM
Sorry for butting in, I'm not a programmer, but I wondered... how is it that there were some programs in the past that could stay in a locked/paused state when a call came in? Gameloft's Ferrari GT -- this is an older game now -- could definitely do this.

You "fake it" by pausing the game when you lose focus, and saving the game when you get the termination message. When the game is started again, you look for a saved game file and load it if it exists. That's What I do in "Dead Panic."

mkrishnan
Nov 11, 2009, 07:12 PM
You "fake it" by pausing the game when you lose focus, and saving the game when you get the termination message. When the game is started again, you look for a saved game file and load it if it exists. That's What I do in "Dead Panic."

That's possible, but it doesn't seem to be what that old app did -- now granted, this was some time and a number of OS revisions ago. It came back pretty instantly in paused mode (as opposed to any loading delay). I'd be curious to load it back on my iPhone and see if it still does this.