Answered: Sencha Touch 2.2.1 - Detect if app active in iPhone (after unlock or made active app
I've been making fairly good progress with iPhone and Sencha Touch 2.2.1 until I found an issue. I've been using a timer in the background (it's actually an Ext.util.delayedTask) and it works great until the iPhone locks or another app becomes active etc...
I've been looking at a few ways around this, such as using localStorage to define the timestamp when the timer started and then when the app becomes active again, simply compare the timestamp to current date/time and see what the difference is and perform an action.
Problem is, I can't for the life of me figure out what I need to call in Sencha Touch 2.2.1 in order to detect whether the app has become the active app again... Can anyone help please!? I've got phonegap installed within the app if that helps at all. I've searched around but can't find anything that clearly defines how to handle this.
DOH! Missed the pause, resume in phonegap as wasn't really sure what they were for... it's all new to me so hang on in there! It says I need to bind those events to the document but if I'm in Sencha Touch code, do I still need to bind them to the document and if so, is this done in the app.js in the launch function, and I assume I can just use:
document.addEventListener("pause", yourCallbackFunction,false);and the same for resume and call a custom function I have in a utility.js file I have set up?