Has anyone implemented an Android Shake Detector that works well on most phones?

I thought it would be fairly simple to implement but I keep getting false results. Basically, what I'm doing is setting up a sensor Listener, checking to make sure it is a SensorManager.SENSOR_ACCELEROMETER event, then only checking the event if the last event I received was more than 50 milliseconds ago (to try to reduce the amount of checking I do)... Then I look for 3 "Shakes" within 4 seconds... A "Shake" to me being a speed reading of over 1000 followed by a speed reading of less than 400 within 1 second.

If I don't get three "Shakes" within 4 seconds then the counter is reset to zero.

At times it seems to work well... but I continue to have instances where I just pick up the phone, and it triggers all three shakes, which makes very little sense to me.. because at other times, I can physically shake the phone quite hard, and not trigger all three shakes... As I said.. it works about 90% of the time correctly, but a 10% error rate is making the feature I want to implement useless.

Anyone have a better formula or some links?

Thanks..,

Brad Gies
-----------------------------------------------------------------------
Bistro Bot - Bistro Blurb
http://www.bgies.com
http://www.bistroblurb.com
http://www.ihottonight.com
-----------------------------------------------------------------------

Never doubt that a small group of thoughtful, committed people can
change the world. Indeed. It is the only thing that ever has - Margaret Mead

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to