Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid the iphone go into sleep mode

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

like image 891
Zeeshan Rang Avatar asked Nov 29 '09 21:11

Zeeshan Rang


People also ask

How do I stop my iPhone from going to sleep?

Turn off all sleep schedules and alarmsTap Browse at the bottom right, then tap Sleep. Scroll down to Your Schedule. Tap Full Schedule & Options, then turn off Sleep Schedule (at the top of the screen). You can turn them all on again later.

Why does my iPhone automatically go to sleep mode?

When people say their iPhone goes to sleep, what they really mean is it enters auto-lock mode after a set time of inactivity. This inactivity is when you don't tap the screen in a certain amount of time. Auto-lock mode is usually set to engage after 2 minutes of inactivity, but this can vary.


2 Answers

Try this

[[UIApplication sharedApplication] setIdleTimerDisabled:YES]; 
like image 146
epatel Avatar answered Oct 03 '22 18:10

epatel


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.

like image 39
KatokichiSoft Avatar answered Oct 03 '22 20:10

KatokichiSoft