1

Why does getIntProperty return zero on the api device 21

val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
val BatteryCapacity = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
Arman
  • 25
  • 7
  • It is possible that the hardware does not support that particular property. – CommonsWare Feb 04 '23 at 13:13
  • FWIW, it is mentioned in [the documentation of `getIntProperty()`](https://developer.android.com/reference/android/os/BatteryManager#getIntProperty(int)): "If the property is not supported or there is any other error, return (a) 0 if targetSdkVersion < VERSION_CODES.P or (b) Integer.MIN_VALUE if targetSdkVersion >= VERSION_CODES.P." – CommonsWare Feb 04 '23 at 13:20

0 Answers0