11

This question is not exactly about code but rather implementation.

I am working on an app that requires to check if the phone is in pocket or not. I have a simple algorithm to detect user steps when walking. The problem is movement in hand can also be registered as a step, e.g. when user runs the app and zeros the step values from the time that he/she does this to the point that the phone is in pocket, the app registeres a few steps.

My idea is to check proximity sensor and see if the phone is in pocket.

What I do with accelerometer sensor is that I continuesly read the accelerometer values in a buffer, when the buffer gets full then I calculate the steps (while calculating, the buffer is still accepting new accelerometer readings).

Since I heard that proximity sensor is interrupt based and not poll-based (like acc sensor is). How can I coordinate these two together?

Is it safe to say if I check proximity before writing acc values into buffer, and check it again when calculation starts, if proximity was not in FAR mode, I can assume the phone was in the pocket?

Any suggestion is welcome!

Ashish Thakkar
  • 944
  • 8
  • 27
Dumbo
  • 13,555
  • 54
  • 184
  • 288
  • 1
    Why don't you access the camera? This won't be a catch-all, but you could do some image processing to determine if the camera sees all black. – bblincoe Jun 25 '14 at 13:46
  • That just extra work and battery use... – Dumbo Jun 25 '14 at 13:47
  • Set it up to poll the camera. I don't know your exact problem space, but you could check once every minute. What's the response time you're looking for? – bblincoe Jun 25 '14 at 13:48
  • How about a short timeout? (1) Reset Steps (2) wait a few seconds (3) start counting. – lupz Jun 25 '14 at 13:49
  • 1
    @lupz no cant do...what about when user pulls the phone out of pocket? guys seriously! – Dumbo Jun 25 '14 at 13:49
  • 1
    you could use google's new awareness api to know wether the user is walking, running or still, and use that in your interest. You should take in count that there's no real way of detecting wether a device is in a pocket or not just by using telemetry data from the phone, aside from checking with the camera if it's all dark *while* walking and *while* it's not night. which is unfeasible. – CptEric Jan 09 '17 at 10:49
  • @Saeid Yazdani, Did you find the solution? I do am working on a project where my app need to check if the phone is in pocket or not. – Shree Jan 30 '18 at 09:34
  • @Divyashree nope – Dumbo Jan 30 '18 at 17:20

0 Answers0