Search code examples
androidsensorsproximity

Need to know if phone is FAR or CLOSE to user's ear while in a call


I want to track the phone's position while the user is in call. I don't want to register the proximity sensor for it because it's redundant and I don't want to count that sensor battery consumption on me, the system uses the proximity anyway when a call starts.

My question is how can I get the position ("far"/"close" in Android logs terminology) of the phone relative to the user's ear?

Thanks Bush


Solution

  • As far as I know, the proximity sensor is the best way to check the distance from the user's face.

    However, if you're willing to come up with some good algorithms, you could try using the accelerometer and the microphone. However, the microphone may not be available to two apps at once.

    If the user's device is touching their face, there will be less accelerometer movement that varies from one direction to another. However, if the phone is held away, there will be some shaking. And if there is no change in the accelerometer readings at all, it is likely lying on a desk, and the user is talking on loudspeaker or using a headset.