Added in API Level 3
Sensor.TYPE_LIGHT:values[0]: Ambient light level in SI lux units
1. Register a SensorEventListener named mySensorEventListener.
2. In the method named onSensorChanged in the SensorEventListener, add the following code. This will test to determine if the sensor type that changed is a Light Sensor (TYPE_LIGHT), then if it is, it declares and sets a new float variable named myEventValue to the saves the event values of the Light Sensor. The next line will display a toast with the current reading of the Light Sensor, which converts the float to a string of float myEventValue.
if(event.sensor.getType()==Sensor.TYPE_LIGHT){
Toast.makeText(getBaseContext(), "Current Reading: " + String.valueOf(myEventValue), Toast.LENGTH_LONG).show();
}
Resources: