• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Android: Detecting "Shake" using accelerometer

 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write a simple application that responds to "phones shake event".I am using openintents simulator to emulate the accelerometer of the android phone.
The onSensorChanged() function of the SensorListener is invoked every time the sensor values change. The values are set of readings(acceleration) along X-Y-Z axis. I need to make sense of these readings, as in, detect that a shake has happened.

Currently, i am using the sum of differences( acceleration along X, Y and Z) and comparing it with a sufficiently large integer to detect a "shake".

Is there a model for this? How can one interpret that the phone was shaken using these three values? I was expecting a specialized "shake" event in the api that would be invoked when the event happens.
 
Rajesh Gopu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
• Channels, X, Y and Z. Each channel represents acceleration force vectors in relation to the phone.

Example: A reading of Z = 1000; X = 0; Y = 0 indicates that downwards acceleration is 1000x10-3 = 1.0 G,
which in turn means that the phone is being held horisontally with the screen facing straight upwards.
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Rajesh "please check your private messages for an important administrative matter. You can check them by clicking the My Private Messages link above.
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rajesh..

Thanks for your reply. I understand the implications of accelerometer readings; what i want is a model which would help "detect" a shake event.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic