是否可以更改 Android 接近传感器的最大范围?

Is it possible to change the maximum range on the Android proximity sensor?

我可以使用接近传感器检测比 sensor.getMaximumRange() 返回的最大范围更远的物体吗?我现在得到的是 8 厘米,而不是 50 厘米?

我不这么认为。通常接近传感器会返回 0 or max range,因为这通常用于在您打电话时头部靠近 phone 时关闭屏幕。

Note: Some proximity sensors only support a binary near or far measurement. In this case, the sensor should report its maximum range value in the far state and a lesser value in the near state.

之后它确实取决于 phone 的硬件,但我怀疑您是否可以超出 maxRange 值。你还是可以看看 aosp about the sensor stack but the native fragment is close to what android.hardware is.