First, you must have a device with the thermometer sensor (a temperature sensor type). Then you might use it.
To check for the sensor, in code use SensorManager:
//get sensor manager first
SensorManager sensorMgr = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
then use getSensorList and look for TYPE_TEMPERATURE .
Tips:
Note, the temperature updates might be "slow" i.e. there might be one or two updates per minute. You might also consider to alow to calibrate your results (i.e. allow add/substract units to the built in sensor results based on a real measured temperature).
BTW: For an outside temeratures, you might use "current outside temperature" from the weather services like METAR (based on the current device location).