tags:

views:

82

answers:

1

To preface this question: I've never actually done iPhone development. Haven't even downloaded the SDK yet. This question arose while I was brainstorming about what kind of app might be interesting and feasible for me to create. That said...

I know the iPhone doesn't (yet) support multi-tasking, but I'm curious what happens when it goes into sleep mode. I notice on my wife's iPhone that if I don't "do" anything for a period of time it goes into sleep mode. The screen blanks, etc.

So would it be possible to create an app that did "something" every ~10s without respect to user input? Or would that app stop doing "something" as soon as the phone goes to sleep?

+1  A: 

Hi There are ways to keep an app from going to sleep. You can even dim the screen etc. to save battery, while still running the app.

Apple has strict guidelines for when you should do this.

Try reading up on the HIG, it will answer all the questions you have, but yes it is possible.HIG

RickiG
Just looked through the HIG and didn't see anything about sleep mode, but if you say its possible then I'll take your word for it.Essentially what I was hoping to do is have my app periodically sample the user's location (without any prompting) and do something with that information. That wouldn't be possible if sleep mode automatically suspended the current app.
My running app samples location and faces the same need - you can keep the iphone out of sleep mode if desired. However, you can't dim the screen (in a kosher way).
BankStrong
So in other words it would totally kill battery life, since the screen would need to stay lit the entire time. Sort of like how the "camera" application works. Hmm. That's unfortunate.
Try looking at an app like "GPS Lite" from "MotionX".They keep the phone from sleeping (so does many games, especially strategy/puzzle games as the user might need more time before interacting) the also provide at "fake" way of dimming and locking the screen. Basically you start it, lock the screen and put it in your pocket.PS. so sorry, it was in the "iPhone Programming Guide", no the HIG.http://developer.apple.com/iPhone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ApplicationEnvironment/ApplicationEnvironment.html#//apple_ref/doc/uid/TP40007072-CH7-SW59
RickiG