How do I get the temperature of the battery in android?
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.
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)…
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.
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.
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.
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";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With