Here you can find how to register for battery changes. Using the extra value ( EXTRA_TEMPERATURE), you can get the temperature.
In short (taken from the link above and slightly modified):
Declare Broadcast Receiver:
private BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver(){
@Override
public void onReceive(Context arg0, Intent intent) {
int temperature = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0);
....
}
};
and in onCreateadd:
this.registerReceiver(this.mBatInfoReceiver,
new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
source
share