简体   繁体   English

错误:(172,25)错误:BatteryManager()在BatteryManager中不公开; 无法从外部包android访问

[英]Error:(172, 25) error: BatteryManager() is not public in BatteryManager; cannot be accessed from outside package android

I am using below code and its working properly with compileSdkVersion 22 我使用下面的代码,它与compileSdkVersion 22正常工作

int capacityValue=new BatteryManager().getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);

but when trying to change compileSdkVersion 23 then its displaying compile time error 但是当试图更改compileSdkVersion 23它显示编译时错误

Error:(172, 25) error: BatteryManager() is not public in BatteryManager; 错误:(172,25)错误:BatteryManager()在BatteryManager中不公开; cannot be accessed from outside package android 无法从外部包android访问

plz help me. 请帮助我。

You have to register a reciever and get the info from the received intent. 您必须注册接收者并从收到的意图中获取信息。

Some sample code here: http://mobiledevtuts.com/android/android-sdk-get-device-battery-information/ 这里有一些示例代码: http//mobiledevtuts.com/android/android-sdk-get-device-battery-information/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM