UIApplicationExitsOnSuspend for Android - Need a different fix?

So, I implemented what is the suggested fix for the missing UIApplicationExitsOnSuspend within Android build settings which is: -

local function onSystemEvent(event)     if event.type == "applicationSuspend" then         native.requestExit()     end end Runtime:addEventListener("system", onSystemEvent)

This works a treat until my app loads the Camera.  Then the app closes down!  I guess the app is placed into an applciationSuspend state when the Camera is loaded.

Any other ideas?  What I need is for the app to exit when the screen locks, but not to close when it loads the camera from within the app!

Of course on IPAD it works without any issues, mainly because IPAD has the UIApplicationExitsOnSuspend … 

Any help would really be appreciated…

Don’t call requestExit() on suspend.    On iOS your app should not exit on suspend and I’m pretty sure Apple will reject an app that does.  Android users are a little more accepting of apps that exit, but it’s still a bad user expereince and if you’re app needs to call the camera, then it cannot exit on suspend.  You can’t have it both ways. 

Rob

Ok, thanks Rob.  The end users want the app to auto switch off when the IPAD or Tablet goes to sleep.  

I set a global variable when the camera loads which stop the app being suspended.  However when this flag is not set (when the camera is not loaded) then the app will shut down.

The IPAD apps work this way and Apple are OK with them…  

Engineering had a great suggestion.  When someone presses a button to launch the camera set a flag somewhere that your suspending because of that.  Then in your system event handler when you get a suspend event, check the value of that flag.  If its not set, then call native.requestExit(), if it is set, don’t.  In other words, you know when your about to suspend yourself in situations where you do not want to exit.  When you get an unexpected suspend is when you want to exit.

Rob

Don’t call requestExit() on suspend.    On iOS your app should not exit on suspend and I’m pretty sure Apple will reject an app that does.  Android users are a little more accepting of apps that exit, but it’s still a bad user expereince and if you’re app needs to call the camera, then it cannot exit on suspend.  You can’t have it both ways. 

Rob

Ok, thanks Rob.  The end users want the app to auto switch off when the IPAD or Tablet goes to sleep.  

I set a global variable when the camera loads which stop the app being suspended.  However when this flag is not set (when the camera is not loaded) then the app will shut down.

The IPAD apps work this way and Apple are OK with them…  

Engineering had a great suggestion.  When someone presses a button to launch the camera set a flag somewhere that your suspending because of that.  Then in your system event handler when you get a suspend event, check the value of that flag.  If its not set, then call native.requestExit(), if it is set, don’t.  In other words, you know when your about to suspend yourself in situations where you do not want to exit.  When you get an unexpected suspend is when you want to exit.

Rob