views:

18

answers:

1

Is there a way to differentiate when a user is exiting an app because he/she pressed the home button or because it's receiving a phone call? in iOS 4.0 the app doesn't quit if the user answers a call but it does in 3.x.

I'd like to save my app state if the user is interrupted by a call or any other phone event but not if the user exits the app by pressing the home button.

Any advice??

+1  A: 

The following application delegate methods get called in different situations:

  • applicationWillTerminate - user pressed "home" button and application is about to exit

  • applicationWillResignActive - user got incoming call or sms alert. if he decides to accept the call the application will quit

  • applicationDidBecomeActive - user ignored incoming call

  • applicationDidEnterBackground - user pressed "home" button and application went to background mode - applicable for platforms that support multitasking

So it seems you need to use applicationWillResignActive: method in app delegate to distinguish between your two cases

Vladimir
Beat me to it ;)
ing0
Thanks Vladimir, I was aware of these methods but kind of confused in the way they are called. I've been doing tests in 3.x and 4.x devices and they seem to behave differently, hence my confusion.
Enmanuel G