سؤال

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 :)

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top