-
- 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceSentryShakeDetector.Listener
-
Constructor Summary
Constructors Constructor Description SentryShakeDetector(ILogger logger)
-
Method Summary
Modifier and Type Method Description voidstart(@NotNull() Context context, @NotNull() SentryShakeDetector.Listener shakeListener)voidstop()voidclose()Stops detection and releases the background thread. voidonSensorChanged(@NotNull() SensorEvent event)voidonAccuracyChanged(@NotNull() Sensor sensor, int accuracy)-
-
Method Detail
-
start
void start(@NotNull() Context context, @NotNull() SentryShakeDetector.Listener shakeListener)
-
stop
void stop()
-
close
void close()
Stops detection and releases the background thread.
-
onSensorChanged
void onSensorChanged(@NotNull() SensorEvent event)
-
onAccuracyChanged
void onAccuracyChanged(@NotNull() Sensor sensor, int accuracy)
-
-
-
-