LightSensor
Last Updated On 2021-07-16
Version 1MinSDK 7Tutorial Video
A sensor component that can measure the light level.
Properties
You can set the below properties in the UI part of the builder.
- Enabled - it's a boolean value which is set to true by default.
- RefreshTime - it's a non negative integer value which is set to 1000 by default.
Block Properties
You can set the below blocks properties in the blocks section of the builder.
Available
Specifies whether or not the device has the hardware to support the LightSensor component.
AverageLux
The average of the 10 most recent light levels measured, in lux.
Enabled
If enabled, then device will listen for changes.
Lux
The most recent light level, in lux, if the sensor is available and enabled.
RefreshTime
The requested minimum time in milliseconds between changes in readings being reported. Android is not guaranteed to honor the request. Setting this property has no effect on pre-Gingerbread devices.
Events
You can set the below event blocks in the blocks section of the builder.
LightChanged
Called when a change is detected in the light level.