Android的光传感器不触发事件 [英] Android light sensor not triggering event

查看:402
本文介绍了Android的光传感器不触发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

经过一番研究,我意识到,没有办法直接读取传感器的照度值。那么,如何让流明值,如果它是恒定的,因此绝不会触发一个事件?有没有一种方法,以初始设置一个假值(比如-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!

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.

这篇关于Android的光传感器不触发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆