San*_*mar 5 battery consumption ios
我想以编程方式获取应用程序的电池使用情况.iOS 8提供电池使用监视器实用程序,我想知道Apple如何实现此功能.这有什么公共API吗?
我希望我的iOS应用程序的电池消耗值为x mAh/min或当前电池状态的x%或任何类似格式.
请帮助.
如果您按照以下代码操作就可以
if (![[UIDevice currentDevice] isBatteryMonitoringEnabled])
{
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
}
NSLog(@"battery : %f", [[UIDevice currentDevice] batteryLevel]);
Run Code Online (Sandbox Code Playgroud)
另外还有一些针对您问题的链接 - How to get real time Battery Level on iOS with a 1%粒度
| 归档时间: |
|
| 查看次数: |
2800 次 |
| 最近记录: |