dor506
dor506

Reputation: 5404

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!

Upvotes: 4

Views: 3735

Answers (1)

molnarm
molnarm

Reputation: 10031

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.

Upvotes: 1

Related Questions