views:

39

answers:

1

I need to find a way to detect when a device has been locked, or else a way to detect when the device has been unlocked, and sent straight to the app where it left off. Is there some method like:

- (void)applicationDidBecomeActiveAfterLockScreen:(UIApplication *)application
A: 

For detecting when phone is being unlocked and application is becoming active again, there is

- (void)applicationDidBecomeActive:(UIApplication *)application

method.

When the device is locked, a method

- (void)applicationWillResignActive:(UIApplication *)application

is called.

Both methods belong to the UIApplicationDelegate protocol.

See UIApplicationDelegate Protocol Reference.

macbirdie
Those happen at other times too, like an incoming phone call.
progrmr
is there a time limit on applicationWillResignActive, like on applicationWillTerminate, how if the function takes more than 5 seconds the function code execution is terminated.
Hankweb