How to Determine if Android Device has Light Sensor, using SensorManager

Needs API Level 3, or greater.
For API Level 7 and above you may use, How to Determine if Android Device has a Light Sensor, using PackageManager.

1. Get the Default Light Sensor with a Sensor named mySensor.

2. Add the below code to the onCreate method. This will test the mySensor to determine if light sensor is available. It will display a toast as determined.

if (mySensor == null){
Toast.makeText(this,  "No Light Sensor Available", Toast.LENGTH_LONG).show();
Toast.makeText(this,  "Light Sensor Available", Toast.LENGTH_LONG).show();

3. Compile and run!