Package 

Class SentryShakeDetector

  • All Implemented Interfaces:
    android.hardware.SensorEventListener

    @ApiStatus.Internal() 
    public final class SentryShakeDetector
     implements SensorEventListener
                        

    Detects shake gestures using the device's accelerometer.

    The accelerometer sensor (TYPE_ACCELEROMETER) does NOT require any special permissions on Android. The BODY_SENSORS permission is only needed for heart rate and similar body sensors.

    Uses a rolling sample window: if more than 75% of accelerometer readings in the past 0.5s exceed ACCELERATION_THRESHOLD, a shake is detected. Based on Square's Seismic library.

    Sensor events are delivered on a background HandlerThread to avoid polluting the main thread.

    • Method Summary

      Modifier and Type Method Description
      void start(@NotNull() Context context, @NotNull() SentryShakeDetector.Listener shakeListener)
      void stop()
      void close() Stops detection and releases the background thread.
      void onSensorChanged(@NotNull() SensorEvent event)
      void onAccuracyChanged(@NotNull() Sensor sensor, int accuracy)
      • Methods inherited from class android.hardware.SensorEventListener

        onAccuracyChanged, onSensorChanged
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait