3

I currently use the proximity sensor of an HTC Wildfire phone. The problem is that it only returns a boolean value if there is an object within 1 cm in front of the sensor.

So, I want to ask if there is an Android phone available in the market that has a proximity sensor which is able to return actual distance values (cm) instead of a boolean..

Thank you

JimmyD_84
  • 31
  • 3
  • this isn't really a programming question – dylan murphy Jun 16 '11 at 13:29
  • 2
    Maybe...maybe not. But it's a good question, and one that I'd like answered, too. In the interest of programming, it's nice to not have to buy every phone on the market just to see if a line of code works or not. – SMBiggs Feb 17 '12 at 08:21

1 Answers1

2

Yes it is possible to obtain actual distance from the phone surface.

In fact ALL hardware sensors DO provide this information. But unfortunately the sensor API defined in Android defines the proximity to be a boolean i.e NEAR(1) OR FAR(0).

To get a boolean reading from the actual distance, the distance obtained from the proximity sensor hardware is compared with a threshold value. This is often done in the sensor-HAL.

Also some light/proximity sensor-hardware ICs provide a proximity boolean themselves. In this case, the threshold is configurable in the hardware. The hardware compares each sample obtained with the threshold internally and then reports the boolean "proximity".

Irrespective of the kind of sensor hardware in use, Android (upto v4.1 "jelly-bean") does NOT expose the proximity distance parameter as part of its sensor API. One can modify the sensor-HAL or try to interact with the proximity sensor driver directly (usually a sys-fs entry).

More details of Light/Proximity sensor on Android.

TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130