Page 1 of 1

Android ExitonSuspend

Posted: Thu Jul 31, 2014 1:42 pm
by Marco Spera

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


Android ExitonSuspend

Posted: Thu Jul 31, 2014 2:05 pm
by Evgene Karachevtsev

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...


Android ExitonSuspend

Posted: Thu Jul 31, 2014 2:11 pm
by Marco Spera

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"?


Android ExitonSuspend

Posted: Thu Jul 31, 2014 2:23 pm
by Kateryna Grynko

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.


Android ExitonSuspend

Posted: Thu Jul 31, 2014 2:24 pm
by Marco Spera

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)


Android ExitonSuspend

Posted: Thu Jul 31, 2014 2:59 pm
by Kateryna Grynko

Hi Marco,

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


Android ExitonSuspend

Posted: Thu Jul 31, 2014 4:28 pm
by Marco Spera

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!