How to make Android app resume right were it stopped after pressing Home button

Hi all,

I am looking for equivalent to  UIApplicationExitsOnSuspend = false  on Android.

So if my character is jumping, and while he is in the air you press Home button on your Android phone.

Can Android phones preserve that state in any way, so when you return by clicking on game icon your game continues from that place (i.e. character falls on the ground)?

That is exact what happens when you activate  UIApplicationExitsOnSuspend = false  on iOS.

Code from following post does not work, i.e when I press Home button, and rightafter press game icon: game restarts right from very beginning - i.e. splash screen.

https://forums.coronalabs.com/topic/37653-uiapplicationexitsonsuspend-not-working-on-android/

If above preserving app state is not possible, how to implement that when you press Home button user gets dialog: “Are you sure you want to exit?, {Y, N}” (and app exits only if user press “Y”) ?

Many, many thanks!

G

I’m working on a couple projects that target Android, and they both seem to exhibit the behavior you’re looking for, without any specific modification on my part. The only non-standard entry in my main.lua (aside from any project-specific customization) is disabling the idle timer.

Which Android version are you testing on? Corona build version? Have you tested this behavior using the sample projects Corona provides?

The default behavior on Android is to suspend your app in its current state (and not completely close the app).

https://coronalabs.com/blog/2012/07/17/using-system-events-to-save-app-state/

On Android you cannot intercept the Home button.

Alex,

I am testing on Samsung S3, Android 4.3
I am using latest Corona stable build.

I will try disabling subject timer in main.lua

Tnx Jon.

I will let you know the results…

Hi Alex,

Disabling idle timer did the trick!

Many thanks!

Goran

Hmm… that is strange. I was always of the same mind as JonPM, which is that the default behavior is not to completely exit the app when tapping the home button. I’ll have to do some additional testing to see what happens in other projects.

Glad that it’s working for you now, though!

I can say with 100% certainty that on Android the home button does not automatically kill the process.  The default behavior is to suspend the app.  Now I’m not certain how it works with Corona objects like timers, physics, composer, etc.  

I’m working on a couple projects that target Android, and they both seem to exhibit the behavior you’re looking for, without any specific modification on my part. The only non-standard entry in my main.lua (aside from any project-specific customization) is disabling the idle timer.

Which Android version are you testing on? Corona build version? Have you tested this behavior using the sample projects Corona provides?

The default behavior on Android is to suspend your app in its current state (and not completely close the app).

https://coronalabs.com/blog/2012/07/17/using-system-events-to-save-app-state/

On Android you cannot intercept the Home button.

Alex,

I am testing on Samsung S3, Android 4.3
I am using latest Corona stable build.

I will try disabling subject timer in main.lua

Tnx Jon.

I will let you know the results…

Hi Alex,

Disabling idle timer did the trick!

Many thanks!

Goran

Hmm… that is strange. I was always of the same mind as JonPM, which is that the default behavior is not to completely exit the app when tapping the home button. I’ll have to do some additional testing to see what happens in other projects.

Glad that it’s working for you now, though!

I can say with 100% certainty that on Android the home button does not automatically kill the process.  The default behavior is to suspend the app.  Now I’m not certain how it works with Corona objects like timers, physics, composer, etc.