ShakeDetector
constructor(sensorManager: SensorManager?, threshold: Float = DEFAULT_THRESHOLD_G, minimumShakes: Int = DEFAULT_MINIMUM_SHAKES, minimumDurationMillis: Long = DEFAULT_MINIMUM_DURATION_MILLIS, cooldownMillis: Long = DEFAULT_COOLDOWN_MILLIS, elapsedRealtime: () -> Long = SystemClock::elapsedRealtime, onShake: () -> Unit)(source)
Parameters
sensorManager
Platform sensor service, null on a device that does not expose one.
threshold
Acceleration counted as shaking, as a multiple of gravity. Must exceed 1, the resting reading.
minimumShakes
Shakes the gesture needs before it is reported.
minimumDurationMillis
How long the gesture must last before it counts.
cooldownMillis
Quiet period after a reported shake.
elapsedRealtime
Monotonic clock, replaceable in tests.
onShake
Invoked on the main thread, which is where sensor callbacks are delivered.