Skip to content Skip to sidebar Skip to footer

Android Battery_property_energy_counter Returning Fixed Value?

My app is runnning code bellow in a working thread every 5 seconds. But it returns a fixed value of -9223372036854775808/ Am I missiging anything? BatteryManager batteryManager

Solution 1:

Android 4.4_r1 removed the possibility for apps to request for the BATTERY_INFO permission as stated in this commit.

You have to:

  1. ROOT your device
  2. Download and install the Xposed installer
  3. Install the “Framework" in the "Xposed Installer" and activate "Enable BatteryStats Permission" in "Modules".
  4. Reboot your device

Since now you have unlocked root permissions, you can access to BATTERY_STATS permission.

Solution 2:

  1. I'm not sure but you might required <uses-permission android:name="android.permission.BATTERY_STATS" /> permission.

  2. BatteryManager.BATTERY_PROPERTY_ENERGY_COUNTER is int not long. Try batteryManager.getIntProperty()

  3. Return the value of a battery property of long type If the platform does not provide the property queried, this value will be Long.MIN_VALUE

So maybe the property is just unavailable. If so, try on a different device.

Post a Comment for "Android Battery_property_energy_counter Returning Fixed Value?"