Search code examples
androidseconds

Android Shaking do something after 3 seconds


I'm using this class for shaking event :

http://android.hlidskialf.com/blog/code/android-shake-detection-listener

What I want is: if user shake the device for 3 seconds in a row, than do something :

mShaker = new ShakeListener(this);
            mShaker.setOnShakeListener(new ShakeListener.OnShakeListener () {
              public void onShake()
              {               
                  Log.e("test", "shaking");
              }
            });

thanks in advance :)


Solution

  • have a look at this link

    http://lfhck.com/question/303373/android-shake-detector-too-sensitive

    it is using a SensorEventListener and the onSensorChanged event.