Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

setTimeout running in background for Android (iPhone?)

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?

— asked February 14th 2011 by Ryan Gartin
  • android
  • background
  • iphone
  • settimeout
0 Comments

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.

    — answered February 14th 2011 by Kevin Kiddy
    permalink
    0 Comments
  • 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.

    — answered February 14th 2011 by Kevin Kiddy
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.