I'm using this function to get current battery level of device:
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
UIDevice *myDevice = [UIDevice currentDevice];
[myDevice setBatteryMonitoringEnabled:YES];
double batLeft = (float)[myDevice batteryLevel];
NSLog(@"%f",batLeft);
but the result has a 5% granularity. Example: when the phone battery is at 88%, it only logs a value of 0.85. batteryLevel
only returns values in increments of 0.05. For example: 0.85, 0.9, 0.95 and never returns values like 0.82 or 0.83.
Is there any solution to get a percentage with a higher precision?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…