No battery temperature updates on HTC Hero / Android 2.1

60 views Asked by At

I'm writing an Android app using old Android phones dedicated to temperature monitoring. Now I'm having problem with an HTC Hero running Android 2.1 update-1. It doesn't receive updates of the battery temperature sensor. It only gets an initial value. It does however receive updates of external power plugged in status. If the external power source is changed a new temperature is received.

Is this behaviour set by the hardware or is it anything I can do about it?

I'm using a BroadcastReceiver:

IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
registerReceiver(batteryReceiver, filter);

BroadcastReceiver batteryReceiver = new BroadcastReceiver() {

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d(LOG_TAG, "onReceive, action = " + intent.getAction());

        float temperature = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 999) / 10f;
        boolean externalPower = (intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0);

        // ...
    }

};

This works fine on a Galaxy S4 / Android 4.3.

Like I said, if the external power source is changed (charger is plugged in or unplugged) the receiver is always called, and a new temperature is received.

Re-regestering the receiver doesn't help.

I've tried manually getting the Intent like this in intervals, but the temperature is constant (even if it definitely changed).

handleBatteryIntent(registerReceiver(null, filter));

Seems the temperature is only updated when the external power source status (EXTRA_PLUGGED) has changed.

I've tried two other battery apps, and they have the same problem.

0

There are 0 answers