Use this method to get the default sensor for a given type. Note that the returned sensor could be a composite sensor, and its data could be averaged or filtered. If you need to access the raw sensors use getSensorList.
Parameters: type - of sensors requested
Returns: the default sensors matching the asked type.
1. Declare a Sensor object named mySensor.
2. Get a Reference to SensorManager named mySensorManager.
3. Save Sensor TYPE_LIGHT to integer named intMySensor.
mySensor = mySensorManager.getDefaultSensor(intMySensor);
5. Compile and run!
Resources:
http://developer.android.com/reference/android/hardware/SensorManager.html#getDefaultSensor(int)3. Save Sensor TYPE_LIGHT to integer named intMySensor.
4. Add the below line to the onCreate method. This will get the default light sensor and save it to mySensor.
5. Compile and run!
Resources:
http://android-coding.blogspot.com/2011/10/using-android-device-build-in-light.html