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.
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/