Android的光传感器不触发事件传感器、事件、Android

2023-09-05 07:44:26 作者:回忆发狂 侵蚀了我眼眶ゅ

在使用光感应器,我有其中onSensorChanged()事件永远不会触发的问题。其原因是,当监听器被注册,如果流明值保持不变,有没有这样的变化没有事件。不过,我还是想知道勒克斯值!有0的恒定勒克斯值之间的差,和60000的恒定

经过一番研究,我意识到,没有办法直接读取传感器的照度值。那么,如何让流明值,如果它是恒定的,因此绝不会触发一个事件?有没有一种方法,以初始设置一个假值(比如-1),这样一个事件总会发生?还是我在思考这个问题?

任何援助将大大AP preciated!

解决方案

我是pretty的肯定是没有办法解决这个问题。你只需要希望,在设定的时间量勒克斯的变化,之前直接询问用户。稀释好。

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!

传感器,光电传感器常用的30种术语及简要解释说明

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!

解决方案

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.