iPhone:位置管理器 + adwhirl = 电池耗尽:(
在我的应用程序中,我使用 CLLocationManager 和 AdWhirl。我没有对后台模式进行具体开发:我不希望我的应用程序在后台运行,即当用户按下“主页按钮”时,GPS 位置不应更新。
昨天晚上我按下“主页按钮”,今天早上 iPhone 没电了。这是一台装有 iOS 4.1 的 iPhone 4,未越狱,并且没有运行后台应用程序。
昨天晚上电池电量约为 35%,今天早上电量为 0%(iPhone 已关机)。
我在代理中设置了断点,每次更新 GPS 位置时都会调用该断点。当应用程序处于后台模式时,不会调用委托。所以我认为 GPS 在后台模式下确实被禁用了:好吧。
今天早上,我跟踪电池消耗情况:每 15 分钟大约下降 1%。我觉得有点太多了。
当应用程序进入后台模式时,我应该做一些特定的事情吗?你觉得这1%的下降正常吗?
In my app I am using CLLocationManager and AdWhirl. I have made no specific development regarding background mode: I don't want my app to be working when it is in background, i.e. when the user press the "home button", GPS location should no be updated.
Yesterday evening I pressed "home button", and this morning the iPhone was out of battery. It's an iPhone 4 with iOS 4.1, not jailbreaked, and there is no background app running.
The battery was about 35% yesterday evening, and 0% this morning (iPhone was shutdown).
I have set breakpoint in my delegate, which is called each time GPS location is updated. When app is in background mode, delegate is not called. So I'm thinking GPS is really disabled in background mode: ok.
This morning, I am following battery drain: it's about 1% drop each 15 min. I think it a bit too much.
Should I do something specific when the app goes to background mode? Do you think this 1% drop is normal?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,互联网接入和 GPS 是电池的两大消耗。我根本不知道你所说的正常是什么意思,因为没有其他应用程序正在运行,你已经得出结论,这实际上就是发生的情况:)假设你已经在没有运行任何应用程序的情况下进行了测试,并且每 15 没有获得 1%分钟...
对于 adwhirl,当应用程序进入后台时,尚不清楚它是否已经停止访问互联网,但您可以将其添加到您的应用程序委托中:
(lm 和 adView 是位置管理器对象和 adWhirlView,两者都在我发现通过我在应用程序代理中创建的方法进行所有位置管理更有用。)
Yes, internet access and GPS are two big drains on battery. I don't know at all what you mean with normal, since no other apps are running you've concluded that that is in fact what happens :) Assuming you've tested with NO apps running and didn't get 1% per 15 minutes...
For adwhirl, it's unknown whether it already stops accessing the internet when the app goes into the background, but you can add this to your App Delegate:
(lm and adView are the Location Manager object and the adWhirlView, both declared in the App Delegate. I've found it more useful to do all location managing via methods I make in the App Delegate.)