在Nexus One上光线感应器只返回两个不同的值 [英] Light sensor on Nexus One returns only two distinct values
问题描述
I'm尝试读取我的Nexus One的光传感器的值,但I'mgetting只有以下值:
I´m trying to read the values of the Light Sensor of my Nexus One, but I´mgetting only following values:
10.0
225.0
和在一些情况下一些值要高得多。
and in a few cases some values much higher.
在使用code:
sensorManager = (SensorManager) context
.getSystemService(Context.SENSOR_SERVICE);
sensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
listener = new SensorEventListener() {
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
@Override
public void onSensorChanged(SensorEvent event) {
Log.d(Constants.TAG, "Brightness: " + event.values[0]);
}
};
sensorManager.registerListener(listener, sensor,
SensorManager.SENSOR_DELAY_NORMAL);
}
没有任何人有在Nexus One上或其他Android设备的光传感器的经验? 是C阅读价值的正确方法我$ C $? 我怎样才能得到更好,更准确的价值?
Does anybody have experience with the light sensor on the Nexus One or another Android device? Is my code the correct way to read the values? How can I get better and more accurate values?
推荐答案
您code看起来不错。我收到的值是这样的:10,225,320,640,1280,2600,3200,10240,但我真的需要点设备朝着太阳获得更高的价值。
Your code looks fine. I was receiving values like this: 10, 225, 320, 640, 1280, 2600, 3200, 10240. But I really needed to point device towards sun to receive higher values.
编辑:从可以在手机上使用Android的API来获得光传感器的特性 - 10240是一个可以由该传感器返回的最高值
from light sensor characteristic that can be obtained on my phone by using Android API - 10240 is the highest value that can be returned by this sensor.
这篇关于在Nexus One上光线感应器只返回两个不同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!