PDA

View Full Version : Getting Battery Info - 3.0




Jeremy1026
Mar 25, 2009, 04:08 PM
I am trying to return the battery level of the device. But, no matter what my battery is, it returns 1.0. Here is my code that I am using.



UIDevice *myDevice = [UIDevice currentDevice];

[myDevice setBatteryMonitoringEnabled:YES];
float batLeft = [myDevice batteryLevel];

NSLog(@"%f",batLeft);



Jeremy1026
Mar 25, 2009, 05:01 PM
Solved: This code does work. I just wasn't letting my battery drain enough. It only updates every 5% (from what I can tell.)

mexicanrooster
Jun 19, 2009, 11:56 AM
I am trying to read the battery using 2.2.1 but it fails. Is it only supported by 3.0?

Thx.

Jeremy1026
Jun 19, 2009, 12:05 PM
I am trying to read the battery using 2.2.1 but it fails. Is it only supported by 3.0?

Thx.

Yes, 3.0 only.