简体   繁体   English

iPhone电池电量耗尽

[英]iPhone Battery Drain

I am facing iPhone Battery Drain problem. 我面临iPhone电池耗尽的问题。 In my app, I am using the accelerometer to count the steps. 在我的应用程序中,我正在使用加速度计来计算步数。 I am subscribing to the location manager in order to keep accelerometer active in background (so that it keeps logging steps). 我订阅了位置管理器,以使加速计在后台保持活动状态(以便保持记录步骤)。 Of course I am using a large distance filter so the localization should not cause such a big battery drain. 当然,我使用的是远距离滤镜,因此本地化不会造成这么大的电池消耗。

Location manager setting: 位置管理器设置:

locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
locationManager.distanceFilter=3000;

//Even I had used startMonitoringSignificantLocationChanges also. //即使我也使用过startMonitoringSignificantLocationChanges。

[locationManager startMonitoringSignificantLocationChanges];

Unfortunately, after around 5 hours my battery is empty. 不幸的是,大约5个小时后,我的电池没电了。 In comparison with the app "Moves"( https://itunes.apple.com/in/app/moves/id509204969?mt=8 ) their application is consuming very litle battery yet they still track ALL the activity while the app is in the background. 与应用程序“ Moves”( https://itunes.apple.com/in/app/moves/id509204969?mt=8 )相比,他们的应用程序消耗的电量非常少,但是在应用程序处于运行状态时,它们仍然跟踪所有活动的背景。 I am amazed how they handle battery problem. 我为他们如何处理电池问题感到惊讶。 When they are also using accelerometer & location manager. 当他们还使用加速度计和位置管理器时。 I am very thankful for any guidance offered in this respect on how they achieve this. 我非常感谢他们在这方面提供的指导。

Thanks! 谢谢!

You should look at using the Core Motion framework rather than the location manager. 您应该考虑使用Core Motion框架而不是位置管理器。 Do a search on "Motion Events" in the Xcode help system to find the relevant docs. 在Xcode帮助系统中搜索“运动事件”,以找到相关文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM