3

There are many examples to detect the shake action in Android. However, it is not that easy to detect a single or double tap on the device based on accelerometer data. A normal move or gentle shake may be detected as tap easily. Anybody know how to find out the tap among so many acceleration events?

buddemat
  • 4,552
  • 14
  • 29
  • 49
Ziwei Zeng
  • 691
  • 5
  • 21
  • Have you tried anything so far? What have you looked at? – Blue Ice Feb 27 '14 at 22:34
  • Yes, I tried the shake action according to this: http://stackoverflow.com/questions/5271448/how-to-detect-shake-event-with-android. I also tried the high-pass filter to get the event value I need. I'll try more possible solutions and will update here. – Ziwei Zeng Feb 27 '14 at 23:12
  • Awesome! I'm really glad that you looked at some other information. Once you have that figured out, feel free to edit your question and add that information. – Blue Ice Feb 27 '14 at 23:13

1 Answers1

-1

My experience with the accelerometer is a little limited, but I suppose you could have a thread or a service that constantly monitors accelerometer data.

Within that thread I feel like you could create a vector by adding all of the components (x,y,z) and find the magnitude of the resulting vector. From that, you know if it I'd a tap if you have 2 large resultant vectors in rapid succession (one for when you start the tap, one for when you stop the tap) . Then you could have that release an intent or notify your program in some way.

Feel free to ask any questions you might have about this in comments.

Matt
  • 5,404
  • 3
  • 27
  • 39