Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get temperature of battery on android

How do I get the temperature of the battery in android?

like image 646
Christian Avatar asked Oct 22 '10 13:10

Christian


People also ask

How to check phone temperature on Android phone?

Read on to know how to check phone temperature on your Android phone . To check phone temperature on Android using dial pad method, follow the below steps: Step 2: Dial *#*#4636#*#* and this will automatically open the information pop up Note that this feature is not available on all Android phones. If it is the case in yours, go to method 2.

What is the average battery temperature of an android cell phone?

Battery temperatures are going to vary of course but I have found that the battery in an Android cell phone often remains in the 30 °C range sometimes in the low 40s depending on the phones usage (86 °F – 104 °F)…

Is 43 degrees Celsius too hot for a battery?

If the battery temperature is between 29℃ and 43℃, there isn’t much to worry about. However, once the battery temperature soars past 40, it’s not good for your phone and you should close all the high graphics games and apps.

Why is my phone's battery temperature so high?

If the batteries temperature is above normal then it would likely indicate the battery is heating up but if the battery temperature doesn’t seem to be too hot then the issue could be that the phone itself is heating up.


2 Answers

http://developer.android.com/reference/android/os/BatteryManager.html

public static final String EXTRA_TEMPERATURE
Extra for ACTION_BATTERY_CHANGED: integer containing the current battery temperature.

like image 197
Select0r Avatar answered Oct 25 '22 02:10

Select0r


Try this:

private class mBatInfoReceiver extends BroadcastReceiver{ 

    int temp = 0;

    float get_temp(){
        return (float)(temp / 10);
    }

    @Override 
    public void onReceive(Context arg0, Intent intent) {
        temp = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE,0);
    }

};

then define in your Variable declarations:

private mBatInfoReceiver myBatInfoReceiver;

and in onCreate:

    @Override 
    public void onCreate(Bundle b) { 
        super.onCreate(b);  
        setContentView(R.layout.activity_main);

        // ...
        // Add this

        myBatInfoReceiver = new mBatInfoReceiver();                                     

        this.registerReceiver(this.myBatInfoReceiver,
                              new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

     } 

later call e.g in a OnClickListener()

float temp = myBatInfoReceiver.get_temp(); 

String message = "Current " + BatteryManager.EXTRA_TEMPERATURE + " = " +
                  temp +  Character.toString ((char) 176) + " C";
like image 27
Ingo Avatar answered Oct 25 '22 01:10

Ingo