Android的光传感器不触发事件

编程入门 行业动态 更新时间:2024-10-13 14:24:57
本文介绍了Android的光传感器不触发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在使用光感应器,我有其中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!

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的光传感器不触发事件

本文发布于:2023-11-24 02:33:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623648.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:传感器   事件   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!