views:

268

answers:

2

I don't want my app to go to sleep (shut screen off) unless the user puts it out of its misery. I'm trying what I think is simple code:

- (void)applicationDidFinishLaunching:(UIApplication *)application {  
    application.idleTimerDisabled = YES;

This works most of the time, but the app still occasionally goes to sleep. I'm not sure of the pattern. Is there anything that can reenable the idle timer?

+4  A: 

Some classes (such as MPMoviePlayerController) will enable/disable the idleTimer as part of their normal workings.

rpetrich
ahh. Is there a list somewhere, so I can reset the idletimer after using the offending class?
BankStrong
There is no list that I know of, but as a last resort you can always reset it on an NSTimer
rpetrich
A: 

rpetrich is right.

I was launching a MoviePlayerController out of my app and on the callback I was forced to set idleTimerDisabled to YES again... But there's a remark here because for some reason iphone is discarding this set...

I solved it, this way: - (void)applicationDidFinishLaunching:(UIApplication *)application {
application.idleTimerDisabled = NO; application.idleTimerDisabled = YES; }

omniausente