views:

393

answers:

2

I am building an application for the ipod touch that needs to run for several time (like an alarm clock). I would like to prevent the ipod touch from going to sleep unless the use manually exit the application. Is this possible with the current SDK?

+6  A: 

You can disable the sleep mode:

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
kharrison
This one is right but "sometimes" , I noticed that it does not work (even with such settings, the iphone goes to idle :/) . It's not 100% reproducable, I don't know in which cases it occurs (I was on 3.0 when I noticed that), but if someone has also noticed that and if there's a known way to work around it... :/
yonel
A: 

As kharrison says...

But read-up on what Apple has to say about it here: iPhone Application Programming Guide

For your use-case I think you should consider dimming the screen after a few seconds to minimize power consumption. Also if it is an alarm clock, not to keep the user awake all night:)

RickiG
Sure, thanks for the link
Oscar Del Ben