On Pause, for mobile applications

Hi All,


I am currently trying to put in a timer to time out users after being out of the app for more than 5 minuets, this seems to be proving quite difficult as certain things work and then certain things seem to break and then visa versa when I fix them.


I am currently firing a client action on ready that calls another client action which is "OnPause" in here i run some javascript to call another client action if the application is paused. 


"$(document).ready(function(){
    document.addEventListener("pause", onPause, false);
});
function onPause() {
    $actions.TimeCheck();
}"


Anybody done anything similar and got it working correctly? 

Hi,

I'm not sure where you are calling that but in general the mobile apps should not have jquery available, so better avoid using $.

Also:

 - you need to be careful from not registering the event multiple times or it will give you a lot of weird results.

- the pause event can only be registed after the deviceready so you need to wait for it first (do a listener for deviceready that triggers your action that adds a listener for the pause)


As for the pause event itself, it works only sometimes and depends a lot on the device. Even if the cordova documentation only lists quirks for ios ...the android is as bad since it does not guarantee by that the app javascript is not paused before your action has a chance to run (causing it to be postpones at the same time as resume).


Regards,

João Rosado