-2

Possible Duplicate:
time remaining until charge is complete,iOS

I am using below code to get the battery level

UIDevice *myDevice = [UIDevice currentDevice];
[myDevice setBatteryMonitoringEnabled:YES];
float batLeft = [myDevice batteryLevel];
int i=[myDevice batteryState];

batinfo=(batLeft*100);

But i am not able to figure out, how to calculate/estimate the time remaining in full charge , i.e when battery level = 100%.

I m trying to get something like time remaining full charge = 01:30:10

Suggestions is always appreciated.

Thanks

Community
  • 1
  • 1
Shishir.bobby
  • 10,936
  • 20
  • 69
  • 100

1 Answers1

1

An example of battery specs on Apple's site, you would probably need to record all the devices and use conditions to see which one is which:

  • 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];

Thats all you can do, so anything else an app uses is guesswork and calculations on your half.

Credits -- copied from here, had to do it because you said it is "not what i needed" even though it is the exact answer.

So to conclude it is not possible using the native API, you must setup conditions to find what model the device is and do the calculations by using specs from apple's site.

Community
  • 1
  • 1
MCKapur
  • 9,087
  • 9
  • 57
  • 100