I want to get the battery usage data from code. How can I do that?
Asked
Active
Viewed 62 times
1 Answers
0
Code will be look like below
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
float batteryLevel = [[UIDevice currentDevice] batteryLevel];
//This will give you the battery between 0.0 (empty) and 1.0 (100% charged)
//If you want it as a percentage, you can do this:
batteryLevel *= 100;
Resource Link:
-
Thanks. But I want to get time that I spend for the specific app. For example: Safari: 2.7 hours on screen 56% Instagram: 29 min on screen 10% – gaaamii Jun 20 '16 at 09:59