【问题标题】:iPhone - Start / Stop CLLocationManageriPhone - 启动/停止 CLLocationManager
【发布时间】:2011-05-24 09:51:58
【问题描述】:

这真的源于我昨晚的“头脑风暴”: iPhone Brainstorm - CLLocation in Background - Polling every 15 minutes

当我的应用程序处于活动状态时,我可以在获得正确读数后停止 CLLocationManager。然后在 performSelector afterDelay 之后我可以再次启动它,阅读并停止它。

如果当我有一个计时器运行时应用程序只是在后台运行,它永远不会重新启动 CLLocationManager。我已经注册了后台位置更新,如果我不停止 CLLocationManager 它很好,但对于电池我希望我可以继续启动/停止它。

请指教。

谢谢 詹姆斯

【问题讨论】:

  • 最后我混合使用了以下两种方法。谢谢大家。

标签: iphone background-process cllocation


【解决方案1】:

当应用进入后台时保存当前时间。

当它再次激活时:

  • 如果应用程序进入后台超过 15 分钟 - 启动 CLLocationServices
  • 如果已过

【讨论】:

    【解决方案2】:

    阅读Apple documentation on Location in background。 定时器不能在后台使用。

    如果您保持 CLLocationManager 以正确的设置运行,它只会在发生重大变化时调用位置更新,即用户在蜂窝塔/wi-fi 点之间移动时。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多