问题
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