Get current milliAmps of battery?

  • Replies:3
  • OpenNot stickiedUnanswered
  • Forum posts: 3

Jul 4, 2016 8:59:11 PM via Website

How to get current battery capacity in mA of android device.

I have tried this code, but it gives me value total battery capacity:

public void getBatteryCapacity() {
Object mPowerProfile_ = null;
final String POWER_PROFILE_CLASS = "";
try {
mPowerProfile_ = Class.forName(POWER_PROFILE_CLASS)
} catch (Exception e) {
try {
double batteryCapacity = (Double) Class
.getMethod("getAveragePower", java.lang.String.class)
.invoke(mPowerProfile_, "battery.capacity");
Toast.makeText(MainActivity.this, batteryCapacity + " mah",
} catch (Exception e) {

  • Forum posts: 5

Jul 4, 2016 10:24:19 PM via Website

Try this, This will work:

private Object mPowerProfile_;

private static final String POWER_PROFILE_CLASS ="";

mPowerProfile_ = Class.forName(POWER_PROFILE_CLASS).getConstructor(Context.class).newInstance(this);

double batteryCapacity=(Double)Class.forName(POWER_PROFILE_CLASS).getMethod("getAveragePower", java.lang.String.class).invoke(mPowerProfile_, "battery.capacity");

  • Forum posts: 3

Jul 5, 2016 6:04:53 AM via Website

Hi @Ahm AD
Your code seems to be returned the value of the total battery capacity.
I want to get value of the current battery capacity.

  • Forum posts: 3

Jul 5, 2016 6:13:32 AM via Website

Oh, "PowerProfile" gives me what each component uses when active. It contains only static information from an XML file that defines how the device behave.
How to get current battery capacity in mA?