System Event applicationSuspend + Display updates

I’m having trouble getting any display updates to fire during applicationSuspend.

For instance, my game is a timed puzzle. If I double-tap the home button the application suspends while the multitasking ribbon comes up. That’s fine, I guess, although I have specified UIApplicationExitsOnSuspend = true in build.settings. It does properly exit rather than suspend when single-tapping the home button.

Anyway – when 'suspend’ing the simulator or double-tapping the home button on the device, the code in my systemEventHandler function fires, except that some of that code that updates display objects never gets a chance to complete. I suspect Corona is halting screen updates *before* passing the event to the handler, in which case there’s nothing I can do about it.

Since it’s a timed puzzle app, it’s a cheat to double-tap the button to suspend and then “solve” the puzzle offline, so to speak. My suspend listener stops the timer and hides the puzzle elements on screen. The latter never happens, though, until the application is *resumed*.

Am I missing something?

I’d post sample code but it’s irrelevant. This is a generic concern; you can put any display object creation/manipulation in an applicationSuspend function and you won’t see it happen. [import]uid: 44647 topic_id: 25430 reply_id: 325430[/import]

The applicationSuspend/Exit listener should be firing to allow you to save the state of your app. Corona does not control the timing of the event and in the case of iOS. You are required to quickly save your state and shutdown. If the app takes to long in this suspend/exit event, the iOS will abort the app.

Because of the timing, screen updates are not guaranteed to happen nor can the app control the display during a suspend.

For your game, you could save the time when you get the suspend event and check the time when you resume and make a decision if the user is trying to cheat and abort that game. That would also mean if the device went to sleep, it couldn’t tell the difference from suspending the app by double-clicking the Home button.

You may be able to force the app to close by calling os.exit() in the suspend listener. I’m not sure if that would clear the screen or not before the suspend finishes. Apple frowns on apps exiting like that and may cause your app to be rejected. I don’t recommend that approach, but just something you might try if it’s important.

My solution would be to detect the suspended state and abort the game upon resume.

Edit: If you are worried about the device going to sleep during a game, your app could disable the sleep timer. The user could still suspend the device manually. [import]uid: 7559 topic_id: 25430 reply_id: 102899[/import]

Thanks for the reply. That’s about what I expected. [import]uid: 44647 topic_id: 25430 reply_id: 102909[/import]