I have an app that uses setTimeout every 30 seconds to update status information.
It appears in Android to continue running after I go to home screen. How can I slow the setTimeout down when running in background (and vice-versa) to reduce load?
Also: I can't tell but does anyone know if setTimeout runs in the background for backgrounded iPhone apps?
2 Answers
A few thoughts:
I have my Android app exit when I go to the home screen. You do that by:
mainWindow = Ti.UI.createWindow({ exitOnClose: 'true' });on the main window. If you did this then you would know that timer is not running on home screen since app is not running.
For my iphone app, I have:
Ti.App.addEventListener('resume', appResumeCB);The function appResumeCB gets called when the iPhone app exits background mode (ie returns to active). Maybe there is another event for entering background mode.
A few thoughts:
I have my Android app exit when I go to the home screen. You do that by:
mainWindow = Ti.UI.createWindow({ exitOnClose: 'true' });on the main window. If you did this then you would know that timer is not running on home screen since app is not running.
For my iphone app, I have:
Ti.App.addEventListener('resume', appResumeCB);The function appResumeCB gets called when the iPhone app exits background mode (ie returns to active). Maybe there is another event for entering background mode.
Your Answer
Think you can help? Login to answer this question!