Titanium Community Questions & Answer Archive

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

no sleep mode??

I can't get my iPhone app to work in sleep mode.
I've used Ti.App.idleTimerDisabled = true;
in app.js but the application just stops when the screen is dimmed and enters sleep mode.

am I missing something?

— asked August 13th 2010 by Pedro Sousa
  • iphone
  • sleep
  • titanium

3 Answers

  • I found out if I play a piece of sound and add a timer in the pause event listener, my app continues to function. (except in iphone 3G).
    will this be accepted by apple?


    function duh(){
        sound_test.audioSessionMode = Ti.Media.AUDIO_SESSION_MODE_PLAYBACK; 
        sound_test.looping = true;
        var useless_timer = setInterval(duh,1000);
        Titanium.API.info("pausing APP");
    — answered August 14th 2010 by Pedro Sousa
    1 Comment
    • Interesting find. I'm also interested in an answer to your question.

      — commented August 17th 2010 by Fred Spencer
  • I did a bit more research and it seems timers do continue to work based on what NSTimer can do. Haven't looked through source, but I'm assuming setInterval is one of the timing bridges to that class.


    — answered August 17th 2010 by Fred Spencer
  • Hello,

    I'm facing a similar situation with my timer. When the phone locks the timer stops responding and picks up again when I a "resumed" event is triggered. I tested your solution and seems to offer a workable scenario. My question is how you stop the "useless_timer" from the "resumed" event. I tried clearInterval(duh) but doesn't seem to work. BTW how do you deal with the timer when going into background?



    — answered April 17th 2011 by Vassilis Papakonstantinou
    1 Comment
    • Playing/reading around found that the solution is clearInterval(useless_timer).

      — commented April 17th 2011 by Vassilis Papakonstantinou
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.