Exiting or interrupted?

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??

-------------Problems Reply------------

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

Category:iphone Views:0 Time:2010-10-05

Related post

  • Interrupting a thread from inside a runnable class? (java) 2010-05-08

    I am trying to set up a method inside a class that implements the runnable interface that will set the interrupt status of that class. The reason i want to be able to do it from inside the class is there is some other clean up stuff that i need to ta

  • 'grep -q' not exiting with 'tail -f' 2011-08-24

    I am trying to implement a script that wait for a specific message in a log file. Once the message is logged then I want to continue the script. Here's what I am trying out with tail -f and grep -q: # tail -f logfile | grep -q 'Message to continue' T

  • sys.exit() terminates too quickly? 2011-10-08

    I'm running some code with a sys.exit() call at the end. Without the sys.exit() line, the self.response works just fine and renders the template. But when I call sys.exit(), the page returns blank. It's almost like sys.exit() is interrupting the temp

  • Capturing Ctrl-c in ruby 2010-01-18

    I was passed a long running legacy ruby program, which has numerous occurances of begin #dosomething rescue Exception => e #halt the exception's progress end throughout it. Without tracking down every single possible exception these each could be

  • SQL SERVER 2005 USE statement 2011-06-12

    What is the best way to handle if USE {invalid_database_name} is failed? I would like to ignore the rest of the statements in such cases. This is so as to avoid accidentally run the script on wrong database. Thanks for your suggestion !!! -----------

  • Low level keyboard hook set with SetWindowsHookEx stops calling function in C# 2011-07-22

    I am creating a program that monitors key presses for controlling iTunes globally. It also has a few WinForms (for displaying track information and editing options). The low-level keyboard hook works great for awhile. If I just start up the program,

  • how child thread can notify parent thread to terminate all the other child thread java 2011-12-17

    my problem is following a parent thread create 5 child thread and all the child thread start finding result and the one child thread get the result it have to notify the parent thread that it got the result and terminate all the other child thread --

  • Execute C/C++/Objective-C code file via BASH script (on Mac OS X) 2012-04-07

    So, I need a script which takes a filepath as an input and compiles & executes the code (either C,C++, or Objective-C). I admit I'm not a BASH guru... So, is there a better way to do it? What would you change (and why)? Here's my code... C input=

  • Service v/s AsyncTask 2012-10-28

    I am confused with respect to design of my app. I need to continuously poll a server to get new data from it. I am confused whether Async Task running at fixed interval or Service running is background is better option. The thread will run only when

  • Make CherryPy exit immediately upon receiving a keyboard interrupt? 2011-08-02

    Is there an easy way of making CherryPy perform an os._exit(0) once it gets a ^C interrupt? It would normally wait for all the threads to terminate which is not useful for debugging as I expect it to shut down immediately. --------------Solutions----

  • interruption points and clean exiting 2011-10-31

    See the following code: boost::thread_group threads; boost::barrier barrier(10); thing pThing; for( size_t i = 0; i < 10; ++i ) { threads.create_thread( [&barrier, &pThing]() { while( true ) { // do some stuff with pThing if( barrier.wait(

  • Exit Shell Script Based on Process Exit Code 2008-09-18

    I have a shell script that executes a number of commands. How do I make the shell script exit if any of the commands exit with a non-zero exit code? --------------Solutions------------- After each command, the exit code can be found in the $? variabl

  • How to prevent the ObjectDisposedException in C# when drawing and application exits 2008-09-18

    I'm a CompSci student, and fairly new at C#, and I was doing a "Josephus Problem" program for a class, and I created an Exit button that calls Application.Exit() to exit at anytime, but if C# is still working on painting and the button is pressed it

  • Connection Interrupted. The connection to the server was reset while the page was loading. The network link was interrupted while negotiating a connection 2008-09-23

    I am calling a PHP-Script belonging to a MySQL/PHP web application using FF3. I run XAMPP on localhost. All I get is this: Connection Interrupted The connection to the server was reset while the page was loading. The network link was interrupted whil

  • Interrupts and exceptions 2008-09-24

    I've seen several question on here about exceptions, and some of them hint at interrupts as exceptions, but none make the connection clear. What is an interrupt? What is an exception? (please explain what exceptions are for each language you know, as

  • How can you ensure in java that a block of code can not be interrupted by any other thread 2008-12-03

    exampl: new Thread(new Runnable() { public void run() { while(condition) { *code that must not be interrupted* *some more code* } } }).start(); SomeOtherThread.start(); YetAntherThread.start(); How can you ensure that code that must not be interrupte

  • How to wait in bash for several subprocesses to finish and return exit code !=0 when any subprocess ends with code !=0? 2008-12-10

    How to wait in a bash script for several subprocesses spawned from that script to finish and return exit code !=0 when any of the subprocesses ends with code !=0 ? Simple script: #!/bin/bash for i in `seq 0 9`; do doCalculations $i & done wait Th

  • What is a good Linux exit error code strategy? 2008-12-26

    I have several independent executable Perl, PHP CLI scripts and C++ programs for which I need to develop an exit error code strategy. These programs are called by other programs using a wrapper class I created to use exec() in PHP. So, I will be able

  • How do I gracefully exit a MDI form that has code executing in Delphi 2009-01-26

    I have a MDI application written in Delphi 2007. If the user exits a form within it whilst code is executing it causes an exception, because the code is trying to update a component or use an object that has been freed with the form. Is there anyway

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.222 (s). 11 q(s)