Avoid the iphone go into sleep mode
Asked Answered
B

2

28

I have made an iphone fitness application. The issue i am unable to resolve here is that, while the application is running, the iphone goes in the sleep mode, and hence the accelerometer and sound turns off. Which i dont want to happen.

Is there anyway i can avoid this from happening? If not that, atleast i could increase the time of my iphone to go into sleep mode.

Regards Zeeshan

Bluetongue answered 29/11, 2009 at 21:24 Comment(0)
H
71

Try this

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
Hwu answered 29/11, 2009 at 21:29 Comment(1)
Thank you, I've been searching for that for too long now.Gambier
G
11

As Jacob and epatel said, the [[ UIApplication sharedApplication ] setIdleTimerDisabled: YES ]; is the way you wanted. However, you'd better to implement when the application is interrupted by other signal. It means that you'd implement - (void)applicationWillResignActive:(UIApplication *)application method.

Because, there are enforced interruption on the iPhone/iPod touch. A phone call, push a power button, and so on.

Goggle answered 30/11, 2009 at 1:13 Comment(2)
KatokichiSoft, could you add an example of how to implement this method?Internment
I put this code into (void)applicationWillResignActive, but it only works in the new iPad version. It does not work in the previous version iPad (just be older a little bit)Peppers

© 2022 - 2024 — McMap. All rights reserved.