Search code examples
javaandroidnumbersbatterymanager

Insert point in a number - Android


I've been creating a Battery Status on Android, but the Temperature and the Voltage doesn't come with the Battery Manager, for Example:

I need 28.7ºC, but Battery Manager get 287ºC, in Voltage I need 4.357, but it get 4357, so how do i get this number and insert the point that I need? Thanks!

My code is:

int temperature = intent.getIntExtra("temperature", -1);
int voltage = intent.getIntExtra("voltage", -1);

Solution

  • You can use something like this:

    double temperature = intent.getIntExtra("temperature", -1) / 10;
    double voltage = intent.getIntExtra("voltage", -1) / 1000;
    

    As per this discussion, unit of measurement are "Tenth of centigrade" and "Millivolts" respectively for temperature and voltage in BatteryManager