Reputation: 587
I'm using the following line of code:
BatteryManager.EXTRA_VOLTAGE
to get the battery voltage from 2 Android devices.
One gives me a value of 4347
, which I'm certain translates to 4347 mV
or 4.347 V
.
But on my other device, the value returned is 7
. This can't possibly mean the battery is outputting .007 V
, so is there anything that the second value could represent?
The tablet returning the value of 7
is a TF101, which I believe has a total voltage output of 7.4 V
between 2 batteries. Could the 7
in this case be representing the Volts (not milliVolts)?
Upvotes: 1
Views: 1666
Reputation: 5096
You probably right that some device returns Voltage in Volt instead of mV. Your Asus tablet for example has 7.4[Volt] battery as you could see here: http://www.ebay.com/itm/Original-Genuine-Battery-for-ASUS-Eee-Pad-TF101-TR101-3300mAh-24Wh-C21-EP101-/191392703477 .
In my galaxy Young I get the same things. So I added this function:
public static float getBatteryVoltage(Intent batteryStatus){
int voltage = batteryStatus.getIntExtra(BatteryManager.EXTRA_VOLTAGE, -1);
if (voltage > 1000)
return voltage / 1000f;
else
return voltage;
}
Upvotes: 1