Essential Android Detect Shake Event edit forum

Using Seismic shake detection

Seismic is an Android device shake detection library by Square. To use it just start listening to the shake events emitted by it.

@Override
protected void onCreate(Bundle savedInstanceState) {
    sm = (SensorManager) getSystemService(SENSOR_SERVICE);
    sd = new ShakeDetector(() -> { /* react to detected shake */ });
}

@Override
protected void onResume() {
    sd.start(sm);
}

@Override
protected void onPause() {
    sd.stop();
}

To define the a different acceleration threshold use sd.setSensitivity(sensitivity) with a sensitivity of SENSITIVITY_LIGHT, SENSITIVITY_MEDIUM, SENSITIVITY_HARD or any other reasonable integer value. The given default values range from 11 to 15.

Installation

compile 'com.squareup:seismic:1.0.2'

Table Of Contents
39 ACRA
64 Menu
112 Loader
114 Detect Shake Event
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close