Tuesday, September 1, 2009

Stop iPhone from going to sleep

"The code below will prevent the iPhone from dimming its screen and ultimately going to sleep. Use it wisely as you don’t want your application becoming notorious for being a battery hog :)"

     [UIApplication sharedApplication].idleTimerDisabled = YES;

Reference: Brandon@icodeblog.com

With some good information in the comments:

Santiago Lema Says:

July 23rd, 2009 at 5:10 am

Playing a 1sec silent sound every 10-15 secs does work. The other processes will continue to run as long as this goes on . That’s how I did it in my alarm clock app ( CuteClock ). It surely eats a lot of battery (as opposed to letting the phone lock itself) but definitely much less than leaving the screen on.




No comments:

Post a Comment

Followers