4

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!

dor506
  • 5,246
  • 9
  • 44
  • 79

1 Answers1

1

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.

Community
  • 1
  • 1
molnarm
  • 9,856
  • 2
  • 42
  • 60
  • 1
    Yep I red it, but I need the precise distance anyway. maybe in some "secret" way. – dor506 Oct 24 '12 at 12:54
  • 1
    There's a 'secret' way. And it is to implement your own native wrapper for proximity sensor using NDK. But first you should be sure that sensor hardware supports anything more advanced then just far/close indication. I would find out the exact hardware specification first. – Viktor Stolbin Nov 09 '12 at 12:56
  • i tested sensor in`*#0*#` and it returned me sensor value but when i wanna get that grammatically i can't – SAYE May 11 '18 at 13:38