问题
For my app I need to get the maximum value of light sensor. I thought it was the same for all devices which have light sensor (ie SensorManager.LIGHT_SUNLIGHT_MAX) but according to sample tests made on devices I was wrong.
The problem is that with SensorListener you can only know when the value has changed.
So my question is: How to get maximum value of light sensor (assuming that the user can put a powerfull light in front of the sensor that, ie light value > maximum sensor value) ?
A solution could be looking at value growth but I don't know how to manage it.
回答1:
Use following method :
getMaximumRange()
Implementation :
SensorManager sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
Sensor lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
maxvalue = lightSensor.getMaximumRange();
Source :
http://developer.android.com/reference/android/hardware/Sensor.html#getMaximumRange()
来源:https://stackoverflow.com/questions/13962023/android-get-the-maximum-value-of-light-sensor