Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

- (void)applicationWillResignActive:(UIApplication *)application never gets called

I'm trying to handle phone calls and standby and things of that nature. I added the function

- (void)applicationWillResignActive:(UIApplication *)application

and

- (void)applicationDidBecomeActive:(UIApplication *)application

to my UIApplicationDelegate. When coming out of standby, "applicationDidBecomeActive" always gets called. However the issue is "applicationWillResignActive" never gets called.

I was wondering if anyone has run into this issue and whether or not anyone found a reason.

EDIT

More info, I discovered that my engine's update loop that gets run from applicationDidFinishLaunching was causing me to miss the message. I call

while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, .002, FALSE) == kCFRunLoopRunHandledSource);

to catch all iphone messages but it doesn't seem to catch the resignActive message before becoming inactive.

Attempting to fork a thread for my update loop is causing weird crash bugs. Anyone have any quick fix suggestions?

like image 680
kidnamedlox Avatar asked Dec 26 '09 18:12

kidnamedlox


2 Answers

Its getting called in iOS 4.0 , when the Home button is hit.

The following delegate methods are called when the Home button is hit in iOS 4.0

- (void)applicationWillResignActive:(UIApplication *)application
{
  NSLog(@"Application Did Resign Active");
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
  NSLog(@"Application Did Enter Background");
}

And when you double tap the home button and again relaunch the App , the following delegate methods are called .

- (void)applicationWillEnterForeground:(UIApplication *)application
{
  NSLog(@"Application Will Enter Foreground");
}



- (void)applicationDidBecomeActive:(UIApplication *)application
{
  NSLog(@"Application Did Become Active");
}
like image 196
Biranchi Avatar answered Nov 15 '22 04:11

Biranchi


I don't think

- (void)applicationWillResignActive:(UIApplication *)application

is called when a phone call is received. I think the OS waits for the user to either answer or declines the phone call. If it i declined, then the app says alive and

- (void)applicationDidBecomeActive:(UIApplication *)application

is called. If it is answered, then your app is told to exit and it will receive

- (void)applicationWillTerminate:(UIApplication *)application
like image 34
awolf Avatar answered Nov 15 '22 05:11

awolf