Sleep?

Monkey Targets Forums/iOS/Sleep?

siread(Posted 2011) [#1]
I've noticed that Monkey apps remain alive indefinitely, draining the battery. Is there any way to send the iPhone to sleep after a period of inactivity?


Xaron(Posted 2011) [#2]
Ususally that thing is up to the OS. So it remains in the memory but is sleeping. At least for iOS that should be the way, because it's not running anymore so it shouldn't enter onUpdate and onRender.


MikeHart(Posted 2011) [#3]
Set the update rate inside OnSuspend VERY low and in OnResume back to the original one. That should help a little.


benmc(Posted 2011) [#4]
I go as far as disabling the running of my app in the background from the plist file. It restarts from scratch every time, and I've had to implement some "save as you go" functionality so you can "continue" when starting over, but I noticed the same thing and in my situation, felt I had no choice but to add this flag.


TMK(Posted 2011) [#5]
I don't have a Mac here right now to test it, but I believe it's the following line in didFinishLaunchingWithOptions that makes Monkey apps not sleep:

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];

I think you just have to comment out that line, and it should sleep.

There are 2 other locations that call "setIdleTimerDisabled" based on accelerometer being enabled or not, so not sure if we need to change those too though.