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

381 Views Asked by At

I am using below code and its working properly with compileSdkVersion 22

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

but when trying to change compileSdkVersion 23 then its displaying compile time error

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

plz help me.

1

There are 1 best solutions below

2
user6547359 On

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/