Search code examples
androidandroid-sensorsproximity

Is there a way to get the precise distance of a proximity sensor from an object?


I want to get the precise distance from the device's proximity sensor to live object.

The only thing that I get is "0.0" - for near distance, and "8.0"/"7.0"(vary from on device to other) - for far distance.

thats how I use to get the distance:

@Override
public final void onSensorChanged(SensorEvent event)
{
    final float distanceX = event.values[0];
}

Is there a way to get the precise distance?

thanks in advance!


Solution

  • The guide to position sensors says the following about proximity sensors:

    Most proximity sensors return the absolute distance, in cm, but some return only near and far values.

    so precision is device-dependent.