I'm trying to get access to the CPU temperature of Android devices, specifically the Samsung Galaxy S8 (for use with a GearVR) to be able to display it in the app interface. The TEMPERATURE and AMBIENT_TEMPERATURE sensors don't seem to be available, unless I've done something wrong in my code?
I tried getting the default AMBIENT_TEMPERATURE and TEMPERATURE sensors from the sensor manager, but both return null.
sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
ambTemperatureSensor = sensorManager.getDefaultSensor(Sensor.TYPE_AMBIENT_TEMPERATURE);
if(ambTemperatureSensor == null)
message += "No ambient temperature sensor...\n";
temperatureSensor = sensorManager.getDefaultSensor(Sensor.TYPE_TEMPERATURE);
if(temperatureSensor == null)
message += "No temperature sensor...\n";
I was fully expecting the AMBIENT_TEMPERATURE sensor to show up and give me access to the CPU temperature, but when that didn't work I thought maybe the deprecated TEMPERATURE sensor would be available instead. Do I need to do anything prior to calling getDefaultSensor?