Search code examples
androidandroid-sensors

Getting the Sensor.TYPE_LIGHT value


Is there any sticky data to get the Sensor.TYPE_LIGHT values. I don't want to always be monitoring for the event change, but under certain circumstances I would like to get the value of the Light Sensor to react accordingly.

Having a sensor registered and running 24x7 for what I need doesn't seem like a good idea at all.


Solution

  • No, it isn't possible to just get the current value of a sensor without registering a listener. But you could register a listener, listen for one or more changes (and get the average), and then unregister the listener again.