Android: get the maximum value of the light sensor

For my application, I need to get the maximum value of the light sensor. I thought this was the same for all devices that have a light sensor (i.e. SensorManager.LIGHT_SUNLIGHT_MAX), but according to the sample tests performed on the 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 the maximum value of the light sensor (provided that the user can put a powerful sensor in front of the sensor, i.e. the light flux value> maximum sensor value)?

The solution might look at rising costs, but I do not know how to manage it.

+4
source share
1 answer

Use the following method:

getMaximumRange() 

Implementation:

 SensorManager sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); Sensor lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); maxvalue = lightSensor.getMaximumRange(); 

A source:

http://developer.android.com/reference/android/hardware/Sensor.html#getMaximumRange ()

+3
source

All Articles