Estimated battery time on iOS [duplicate]

守給你的承諾、 提交于 2019-12-01 06:13:57

问题


Possible Duplicate:
iphone: Calculating battery life

I have seen many apps in appstore which provides Estimated battery work time for different usage patterns (standby, audio and video playback, Wi-Fi and 3G browser usage, talk time). I have a similar requirement to compute the estimated time like this. Can someone throw some light on how to do this programmatically?


回答1:


The battery life specs come from Apple's site.

  • Talk time: Up to 8 hours on 3G, up to 14 hours on 2G (GSM)
  • Standby time: Up to 200 hours
  • Internet use: Up to 6 hours on 3G, up to 9 hours on Wi-Fi
  • Video playback: Up to 10 hours
  • Audio playback: Up to 40 hours

The code to get the percentage of battery left is:

[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
float batteryLevel = [myDevice batteryLevel];

That's all Apple and the iOS give you, so anything else an app uses is guesswork.



来源:https://stackoverflow.com/questions/10816335/estimated-battery-time-on-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!