Android - get proximity sensor min and max value

Anonymous picture Anonymous · Feb 11, 2014 · Viewed 6.9k times · Source

The app i am building makes use of the proximity sensor. Trying it in different phones i found that the proximity sensor has different (min,max) values in different phones (my htc sensation has 0 for covered and 9 for uncovered while xperia has 0 for covered and 1 for uncovered).So the question is: How do i get the proximity sensor's min max values ??

Answer

Gopal Gopi picture Gopal Gopi · Feb 11, 2014

I think minimum value for proximity Sensor is 0 for all devices. and to get maximum range...

    SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    Sensor proximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
    proximitySensor.getMaximumRange();