1

I have an iphone game that plays background music using AVSoundPlayer - when someone locks the iphone the music stops which is fine. But when someone unlocks it, I don't want my music to start playing again while you're staring at the "slide to unlock" screen - I want it to start playing once you've actually slid the button and the app is visible again - is there some way to detect this? (I've tried applicationDidBecomeActive but that fires when the phone is unlocked but not when your app is visible yet...)

2 Answers2

0

You could try viewWillAppear.

Dan Lorenc
  • 5,376
  • 1
  • 23
  • 34
  • viewWillAppear unfortunately does not get called since my application technically was still running the whole time... –  Jun 18 '09 at 03:27
0
- (void)applicationDidBecomeActive:(UIApplication *)application;

This sent when your app becomes active

Another answer on SO applicable to your question:

applicationWillTerminate works as long as I don't switch off the iPhone

Community
  • 1
  • 1
Corey Floyd
  • 25,929
  • 31
  • 126
  • 154
  • again, applicationDidBecomeActive is called when the user presses the lock/unlock button, but I want to know when the user actually gets rid of the "slide to unlock" screen itself.. –  Jun 18 '09 at 03:27
  • 1
    I don't think your application becoming active on the touch of the unlock button, even if you don't slide to unlock, is expected behavior. If that is indeed what you are experiencing, I would file a bug. Obviously, if the phone is still locked your app shouldn't be notified that it has become active. – Corey Floyd Jun 18 '09 at 05:29