Marco Spera
Posts: 0
Joined: Tue Jun 17, 2014 7:14 pm

Android ExitonSuspend

Hi,

Upon building my app for iOS, there was an options titled ExitOnSuspend, which would allow my app to exit everytime the home button is clicked. Upon returning to the app, the app would start fresh from the home screen.

Is there a similar option for Android? How could I enable this, so my app does not continue from where it was left, upon exiting/suspending the app?

Thanks

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Android ExitonSuspend

Hi Marco,

You should use event resume to guide the user to the correct page and possible to do extra actions (for example clear LVS etc.)
http://docs.phonegap.com/en/1.6.0/cor...

Marco Spera
Posts: 0
Joined: Tue Jun 17, 2014 7:14 pm

Android ExitonSuspend

I will try it out, thanks.

One more question....

Where can I add javascript so that it applies to everypage, and not just invoked on a certain action? Would i just do this under the "Create New Javascript"?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Android ExitonSuspend

Hi Marco,

However, you would need to run it on every page. If you need to run the same code you can add it to function as "Create New JavaScript", and then call this function, for example, on page Load or Page Show event.

Marco Spera
Posts: 0
Joined: Tue Jun 17, 2014 7:14 pm

Android ExitonSuspend

Would the following code work, rather than having to use the resume function:

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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Android ExitonSuspend

Hi Marco,

This doesn't look like a valid JavaScript code...

Marco Spera
Posts: 0
Joined: Tue Jun 17, 2014 7:14 pm

Android ExitonSuspend

Hi Katya,

You right. I will go ahead and use the pause/resume fuctions that Evgene mentioned. They seem to work perfectly.

Thanks to both of you!

Return to “Issues”