Hi everybody, I'm developing an app and i need to detect when the user shakes the phone from side to side , that means just along one axis (in this case X) . That for i'm reading the values from the accelerometer, a bit of code:
private final double THRESHOLD = 0.2; @Override public void onSensorChanged(SensorEvent event) { if (series!=null){ if (event.values[0] < -THRESHOLD){ moving = LEFT; }else if (event.values[0] > THRESHOLD){ moving = RIGHT; } } } I want to know when the user shakes the phone to the left and when to the right, the problem is that my code does not detect shaking but tilt, i have tested this code and it works when i tilt the phone to left or to the right, but not when a shake it from side to side (no matter the orientation of the phone). ¿do you guys know what i'm doing wrong? ¿how would you code it? i'm testing it on a Samsung galaxy. - i dont what to detect an arbitrary shake , i want to detect the acceleration along the x axis, something in this direction:(from the documentation) When the device lies flat on a table and is pushed on its left side toward the right, the x acceleration value is positive. Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---