Android light sensor not triggering event

前提是你 提交于 2019-12-04 23:39:40

问题


When using the light sensor, I have an issue where the onSensorChanged() event is never triggered. The reason is that when the listener is registered, if the lux value remains constant, there's no change thus no event. However, I still want to know the lux value! There's a difference between a constant lux value of 0, and a constant of 60,000!

After some research, I realised that there's no way to directly read the lux value of the sensor. So how do I get the lux value if it's constant, and thus will never trigger an event? Is there a way to set a false value initially (such as -1) so an event will always occur? Or am I thinking about this wrong?

Any assistance would be greatly appreciated!


回答1:


Check following example, It explained how to use Sensors

Android Light Sensor




回答2:


I'm pretty sure there is no solution to this problem. You just need to hope that the lux changes within a set amount of time, before asking the user directly. Ahh well.



来源:https://stackoverflow.com/questions/6095562/android-light-sensor-not-triggering-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!