CLLocationmanager:节省电池 [英] CLLocationmanager: Save battery

查看:121
本文介绍了CLLocationmanager:节省电池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的新应用程序正在进行使用CLLocationManager的实例有几个目的。为使应用尽可能实现电池友好,位置服务应仅在需要时激活,并在数据刷新完成后立即停用。为了我的目的,完全足够在10秒钟内获取位置数据一次。 (尚未决定确切的时间间隔长度)。

My new "app in progress" uses an instance of CLLocationManager for several purposes. To make the app as battery-friendly as possible, the location services should be activated only if needed, and deactivated immediately when the data refresh is done. For my purpose it's perfectly enough to fetch the location data only once in 10 seconds. (Haven't yet decided the exact interval length).

我的问题是,这是关闭定位服务最节约电池的方法?是否只需使用stopUpdatingLocation方法,并将CLLocationManager自身保留在内存中,或者是否需要释放整个实例,并在下次刷新之前分配一个新的实例?

My question is, which is the most battery-efficient method of "turning off the Location services"? Is it sufficient to just use the "stopUpdatingLocation" method and keep the CLLocationManager himself in memory, or am I required to release the entire instance, and allocate a new one before the next refresh?

推荐答案

我同意 stopUpdatingLocation distanceFilter desiredAccuracy 是要走的路。请注意,当所需精度在公里范围内时,位置管理器甚至可能不必启动GPS。

I agree with the other answers that stopUpdatingLocation in combination with the distanceFilter and desiredAccuracy is the way to go. Note that when the desired accuracy is in the scope of kilometres, the location manager might not even have to fire up the GPS.

同样,根据您使用的是什么,请查看区域监控和重要的位置更新,因为这些更加电池友好。

Similarly, depending on what you use it for, have a look at region monitoring and significant location updates since those are more battery friendly.

相关:位置意识编程指南 - 节省电池电量的提示

这篇关于CLLocationmanager:节省电池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆