Minimizing app on back button

Right now on the final back button press I’m doing native.requestExit(). Instead I would like to minimize the app. That way it will launch again much faster. Anyway to do that in Corona?

We have a hidden feature that will allow you to do this.  Replace your native.requestExit() function with the following…

   system.request(“suspendApplication”)

Thank you Joshua, that is most excellent.

This is a great feature. Thanks for sharing! You mention ‘hidden’ feature. Does this mean it might go away at some point? 

Happy to help!

So far, we plan on keeping this function.  Our Google Play expansion file download screen depends on this function so that when the end-user backs out of the app while it downloads the expansion file, that window will be in the last state it was left in when the user returns.  Just be aware that this function is Android only.  We weren’t sure what to do with it on iOS (it’s bad practice on iOS for an app to home out of itself) which is why we didn’t document it at the time.  But that said, we’ll likely add support for it on Windows Phone and end up keeping it.

Sounds great! Thanks for the background info. IMHO, it would be great to support this feature on IOS as well. Although its bad practice and Apple doesn’t like it there might be valid use cases. This way your API can remain consistent across platforms as well. Just a thought. In any case, thanks much for your help.

I’m not an iOS developer here, but I’m not sure if its possible or not to implement this on iOS.  The closest equivalent I’ve seen is an os.exit() (which is a force quit; not a nice thing to do) to force exit the app.  But the end-user might think that the app is crashing.  Come to think of it, I don’t know of any iOS apps force themselves closed.

I agree. Force quit is not a good thing and I think Apple rejects apps that do this anyways. Suspend could have been nice but if there is no way to do it so be it. Thanks much for your input. 

We have a hidden feature that will allow you to do this.  Replace your native.requestExit() function with the following…

   system.request(“suspendApplication”)

Thank you Joshua, that is most excellent.

This is a great feature. Thanks for sharing! You mention ‘hidden’ feature. Does this mean it might go away at some point? 

Happy to help!

So far, we plan on keeping this function.  Our Google Play expansion file download screen depends on this function so that when the end-user backs out of the app while it downloads the expansion file, that window will be in the last state it was left in when the user returns.  Just be aware that this function is Android only.  We weren’t sure what to do with it on iOS (it’s bad practice on iOS for an app to home out of itself) which is why we didn’t document it at the time.  But that said, we’ll likely add support for it on Windows Phone and end up keeping it.

Sounds great! Thanks for the background info. IMHO, it would be great to support this feature on IOS as well. Although its bad practice and Apple doesn’t like it there might be valid use cases. This way your API can remain consistent across platforms as well. Just a thought. In any case, thanks much for your help.

I’m not an iOS developer here, but I’m not sure if its possible or not to implement this on iOS.  The closest equivalent I’ve seen is an os.exit() (which is a force quit; not a nice thing to do) to force exit the app.  But the end-user might think that the app is crashing.  Come to think of it, I don’t know of any iOS apps force themselves closed.

I agree. Force quit is not a good thing and I think Apple rejects apps that do this anyways. Suspend could have been nice but if there is no way to do it so be it. Thanks much for your input. 

Yesssss… exactly what I wanted :\ I must say, it seems odd to me that the default behavior for the back button is to kill the app altogether, but pressing the home button suspends it. Anyway, thanks for providing this functionality!

Yesssss… exactly what I wanted :\ I must say, it seems odd to me that the default behavior for the back button is to kill the app altogether, but pressing the home button suspends it. Anyway, thanks for providing this functionality!