iPhone - 启动/停止 CLLocationManager
这确实是从我昨晚的“头脑风暴”开始的: iPhone 头脑风暴 - CLLocation 在后台 - 每 15 分钟轮询一次
当我的应用程序处于活动状态时,我可以在获得正确的读数后停止 CLLocationManager。然后,在 PerformSelector afterDelay 之后,我可以再次启动它,读取读数并停止它。
如果当我运行计时器时应用程序只是进入后台,则它永远不会重新启动 CLLocationManager。我已经注册了后台位置更新,如果我不停止 CLLocationManager 就很好,但对于电池,我希望我可以继续启动/停止它。
请指教。
谢谢 詹姆斯
This really leads off from my "brainstorm" last night here:
iPhone Brainstorm - CLLocation in Background - Polling every 15 minutes
When my application is active I can stop the CLLocationManager after I get a correct reading. Then after the performSelector afterDelay I can start it again, take a reading and stop it.
If though the application is but to the background when I have a timer running it never restart the CLLocationManager. I have registered for background location updates and if I do not stop the CLLocationManager it is fine but for battery I was hoping I could keep start/stopping it.
Please advise.
Thanks
James
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当应用程序进入后台时保存当前时间。
当它再次激活时:
Save the current time when the application enters the background.
When it becomes active again:
阅读 有关后台位置的 Apple 文档。
定时器不能在后台使用。
如果您保持 CLLocationManager 使用正确的设置运行,它只会在发生重大变化时调用位置更新,即当用户在手机信号塔/Wi-Fi 点之间移动时。
Read the Apple documentation on Location in background.
Timmers can't be used in the background.
If you keep CLLocationManager running with the correct settings it will only call location update on major change, which is when the user moves between cell towers/wi-fi points.