I'm working on an application that uses the iPhone GPS to acquire a location track. To save power, I want to acquire location data while the screen is off. I've learned the trick of playing a silent audio file to keep the location acquisition going while in sleep mode. I still have an occasional problem with location acquisition stopping in sleep mode. This happens maybe 5 - 10% of the time. I suspect that I may not have a good enough location fix to start with, although the appearance of the current location annotation on the map view seems to imply a good and accurate fix. Does anyone 开发者_StackOverflow社区know a good way to determine definitively that the location manager has a good fix? Does anyone know any tricks for "kicking" the location manager while in sleep mode to keep it going? I tried running a 30 second repeating timer and reading the current location each time it fired. Sadly, this didn't help. Any suggestions are appreciated.
-rich
You can check the returned data from the location manager for the horizontalAccuracy
property, to see if the location is accurate enough or not.
Another way to turn off the display and save battery power without tricks is to enable the proximity sensor, and disable sleep. That way the display will blank when the phone is in your pocket, and light up when you pick it up to look at it.
精彩评论