How to force the app to suspend

Hi community,

I would like that pressing “back” button on the home page has the same effect that pressing the “home” button : suspend the application so that it can be later resumed in the state it was when leaving.

However, the only way I found to leave the app programmatically is native.requestExit() which actually closes the app.

Would there be a native function to simply suspend the app ?

Best regards,

The OS will suspend the app for you.

You may need to try and catch the on suspend event and stop things like physics, timers, transitions, audio, etc. even though most of those things will suspend correctly.

Rob

Hi Rob,

Thanks for your interest in this matter.

I would like to be able to suspend the app programmatically.

On Android, when I uses native.requestExit(), then open the app again, it restarts instead of resuming where it was.

Is there a way to have it resume rather than restarting ?

Best regards,

As far as I know you cannot “force suspend” an app, nor should you want to. This has to do with user experience and in fact, it’s why Apple rejects apps that “exit”. User’s see apps that just disappear as apps that have “crashed” and are buggy and will likely not want to use your app feel they may need to reboot their devices.  While Google hasn’t made this a rule yet, probably because Android users are a bit more used to closing apps to free up memory, it’s still a bad user experience.

On iOS everyone expects to use the Home button or App switching to change apps. On Android people are used to using the soft button bar to either back out to the home screen, bring up a list of running apps that can be flicked away, etc.

native.requestExit() exists in case you insist on having a Quit button in your UI (which is a rejection for Apple) for Android. And it will quit, not suspend. For desktop, having a quit button is more standard. Avoiding the appearance of being buggy or crashing is a goal to try and achieve. Programmatically suspending doesn’t achieve this.

There isn’t a way to resume, unless you save all of your apps state and make the user go through the app startup experience again.

What is your use case for this?

Rob

Hi Rob,

It seems that Android users expect to be able to suspend the app by pressing the “back” button when they are on the homepage. They expect to go back into the app later and return to where they were, not going through the spalsh screen.

We would like to enable this feature on Android only, not on Apple.

If you hit the back button on Android and you do nothing in your code (don’t attempt to exit), it should suspend the app and send it to the background. This should “just work”. The OS will handle this for you.

if you’re catching the back button to navigate out of scenes, simply detect in your back button handler and if you detect you’re back on your home screen, simply do a “return false” indicating that you’re app isn’t handling the press and the OS will handle suspending your app for you.

Rob

The OS will suspend the app for you.

You may need to try and catch the on suspend event and stop things like physics, timers, transitions, audio, etc. even though most of those things will suspend correctly.

Rob

Hi Rob,

Thanks for your interest in this matter.

I would like to be able to suspend the app programmatically.

On Android, when I uses native.requestExit(), then open the app again, it restarts instead of resuming where it was.

Is there a way to have it resume rather than restarting ?

Best regards,

As far as I know you cannot “force suspend” an app, nor should you want to. This has to do with user experience and in fact, it’s why Apple rejects apps that “exit”. User’s see apps that just disappear as apps that have “crashed” and are buggy and will likely not want to use your app feel they may need to reboot their devices.  While Google hasn’t made this a rule yet, probably because Android users are a bit more used to closing apps to free up memory, it’s still a bad user experience.

On iOS everyone expects to use the Home button or App switching to change apps. On Android people are used to using the soft button bar to either back out to the home screen, bring up a list of running apps that can be flicked away, etc.

native.requestExit() exists in case you insist on having a Quit button in your UI (which is a rejection for Apple) for Android. And it will quit, not suspend. For desktop, having a quit button is more standard. Avoiding the appearance of being buggy or crashing is a goal to try and achieve. Programmatically suspending doesn’t achieve this.

There isn’t a way to resume, unless you save all of your apps state and make the user go through the app startup experience again.

What is your use case for this?

Rob

Hi Rob,

It seems that Android users expect to be able to suspend the app by pressing the “back” button when they are on the homepage. They expect to go back into the app later and return to where they were, not going through the spalsh screen.

We would like to enable this feature on Android only, not on Apple.

If you hit the back button on Android and you do nothing in your code (don’t attempt to exit), it should suspend the app and send it to the background. This should “just work”. The OS will handle this for you.

if you’re catching the back button to navigate out of scenes, simply detect in your back button handler and if you detect you’re back on your home screen, simply do a “return false” indicating that you’re app isn’t handling the press and the OS will handle suspending your app for you.

Rob