如何更改 Android 接近传感器的灵敏度?
我编写了一个基于接近传感器的应用程序,但我希望能够让用户能够更改传感器的灵敏度。 是否可以?如果是的话怎么办?
I coded an app based on proximity sensor, but I would like to be able to give users the ability to change the sensitivity of the sensor.
Is it possible? If yes how to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需“实现 SensorEventListener”并遵循代码:
Just "implements SensorEventListener" and follow the code :
我认为这是不可能的。接近传感器由操作系统管理。为了保护用户,应用程序不能在没有 root 访问权限的情况下直接更改操作系统文件。
I dont think this is possible. The proximity sensor is managed by the operating system. To protect users apps can't directly change os files without root access.
Android 中定义的传感器 API 将接近度定义为布尔值,即 NEAR(1) 或 FAR(0)。我认为“灵敏度”指的是阈值距离,低于该阈值距离传感器将接近度报告为“NEAR”。
Android 上的光/接近传感器的更多详细信息< /strong>。
Android(最高 v4.1“jelly-bean”)不会将接近距离参数作为其传感器 API 的一部分公开。
您有以下选项:
修改传感器 HAL 以向接近传感器添加可配置阈值。
直接与接近传感器驱动程序交互(通常是 sys-fs 条目)。
根据所使用的光/接近传感器硬件,
这可能在少数设备上可行,而在其他设备上则不然。
此外,为了进行此类“系统级”修改,Android 设备肯定需要 root。
The sensor API defined in Android defines the proximity to be a boolean i.e NEAR(1) OR FAR(0). By "sensitivity", i presume you mean the threshold distance below which the proximity sensor reports proximity as NEAR.
More details of Light/Proximity sensor on Android.
Android (upto v4.1 "jelly-bean") does NOT expose the proximity distance parameter as part of its sensor API.
You have the following options:
modify the sensor-HAL to add a configurable threshold to proximity sensor.
interact with the proximity sensor driver directly (usually a sys-fs entry).
Depending upon the light/proximity sensor hardware in use,
this maybe possible on few devices and not on others.
Also one would definitely require the Android device to be rooted for such "system-level" modifications.