This question concerns not only the code, but also the implementation.
I am working on an application that requires checking if the phone is in my pocket or not. I have a simple algorithm for detecting user steps when walking. The problem is that the movement in the hand can also be recorded as a step, for example. when the user launches the application and zeros of the step value from the moment when he does it to such an extent that the phone is in his pocket, the application registers several steps.
My idea is to check the proximity sensor and see if the phone is in your pocket.
What I do with the accelerometer sensor is that I continue to read the values ββof the accelerometer in the buffer, when the buffer is full, then I calculate the steps (when calculating the buffer, new accelerometer readings are still accepted).
Since I heard that the proximity sensor is interrupt based and not poll based (like acc sensor). How can I copy these two together?
Can I say if I check the proximity before writing the acc values ββto the buffer and try again when the calculation starts, if the proximity was not in FAR mode, can I assume that the phone was in my pocket?
Any suggestion is welcome!
android proximitysensor proximity
Saeid yazdani
source share