谷歌纵横iPhone版后台运行更新纵横坐标实现原理分析

来源:互联网 发布:剑灵龙女数据 编辑:程序博客网 时间:2024/04/28 01:05

转自:StackOverflow

Running application in background like google latitude

up vote1down votefavorite
2

I'm working nowadays on an application that tracking the user location. I want this application to run even when it's not in the task list (double click on the home button doesn't show it). Like google latitude, the application is not running in background. I think that this document is talking about running application when user press on the home button:http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html

but what if user close this application by double click on the home button? I know that applications like google latitudes are still running in the background. so how can I do that?

share|improve this question
  

2 Answers

activeoldestvotes
up vote1down voteaccepted

Application is able to run again in background in case if it was registered for significant location change when launched last time. If Google latitude launch application back, than they use this flow:

  1. Application launch
  2. Check if device can provide significant location change notification (devices with cellular data may handle this kind of notification): significantLocationChangeMonitoringAvailable
  3. Register for notification: startMonitoringSignificantLocationChanges
  4. Quit app and as soon as your device will leave one cell tower to another, system would send notification and your application will be waked up.

There is a problem, no normal way to unregister from this notification. I think only by providing user an option to stop monitoring. I noticed this, by arrow on top right corner of status bar, which means what someone is using location service.

share|improve this answer

原文:http://stackoverflow.com/questions/7059107/running-application-in-background-like-google-latitude
Apple官方文档:Background Execution and Multitasking
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html%23//apple_ref/doc/uid/TP40007072-CH4-SW20