我测试的接近传感器与此code:
I'm testing the proximity sensor with this code:
final SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); final Sensor proximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); sensorManager.registerListener(this, proximitySensor, SensorManager.SENSOR_DELAY_FASTEST);
当我的手远离传感器和0.0时,它完全关闭传感器我只得到5.0的值。 (我测试在Nexus S,4.1) 我可以得到一个介于0和5的值?
And I'm getting only 5.0 value when my hand is far away from the sensor and 0.0 when it's completely closed the sensor. (I'm testing on Nexus S, 4.1) Can I get the values between 0 and 5?
推荐答案在许多设备中,接近传感器本质上是布尔 - 近(0),或远(5),但是这依赖于实际的使用接近传感器。
On many devices, the proximity sensor is essentially boolean - 'near' (0), or 'far' (5), but this is dependent on the actual proximity sensor used.
我没有Nexus S的,所以我无法验证该设备,但我猜它类似于我的三星GS3,报告如下信息: 名称:GP2A接近传感器 供应商:夏普 版本:1 功率:0.75 最大量程:5.0 分辨率:5.0
I don't have a Nexus S, so I can't verify that device, but I'm guessing that it's similar to my Samsung GS3, which reports the following information: Name: GP2A Proximity Sensor Vendor: Sharp Version: 1 Power: 0.75 Maximum Range: 5.0 Resolution: 5.0
正如你可以在GS3看,分辨率是一样的最大范围内,所以0和5,我要去得到,不管我做什么,唯一的值。
As you can see on the GS3, the resolution is the same as the maximum range, so 0 and 5 are the only values that I'm going to get no matter what I do.
您可以检查出自己的设备使用类似的Android的传感器盒,或使用传感器API 的getMaximumRange()和getResolution()方法。
You can check out your own device by using an app like 'Android Sensor Box', or by using the Sensor API's getMaximumRange() and getResolution() methods.
更多推荐
接近传感器精度
发布评论