Introduction
Background sensor batching
Batching allows the sensor to report sensor events at
a specified frequency.\n\nThe system delays calls to the SensorEventListener and deliver
them in intervals, based on the maximum report latency specified when the listener is
registered. Note that this only means that the call to onSensorChanged() is delayed, the
total number of calls is identical as if no batching was used. Sensors only deliver events
while the CPU is awake. If the CPU is asleep and a batched sensor event listener is still
registered, the sensor will continue to collect events until it runs out of memory and
overwrites old values. This use case is not covered by this sample. (The sensor event queue
should be flushed using a scheduled background thread.) \n\nIn this sample app data is only
collected while the app is running and the CPU is awake. In this case the sensor will
deliver events before the queue fills up.
The age of a sensor event describes the delay between
when it was recorded by the sensor until it was delivered to the SensorEventListener.
Register step detector sensor
Register a listener for the STEP DETECTOR
sensor.\n\nThis sensor delivers an event when the user takes a step. One event is received
per step.
Register step counter sensor
Register a listener for the STEP COUNTER
sensor.\n\nThis sensor triggers events when a step is detected, but applies algorithms to
filter out false positives. Events from this sensor have higher latency than the step
detector and contain the total number of steps taken since the sensor was first registered.
No batching (delay=0)
5s batching (delay=5000ms)
10s batching (delay=10000ms)
Total Steps: %1$d
Step Counter
Step Detector
Sensor: %1$s\nMax sensor event delay: %2$,d \u00B5s\nAge of
events in s:\n%3$s
Error
This sample requires at least Android KitKat (4.4) and a device
with the step sensor.\n\nThis device does not appear to meet these requirements, as an
alternative you may want to consider using the gyro sensor and implement your own step
recognition as a fallback.
The listener has been registered, but batch mode could not be
enabled.\n\nIt is likely that it is not supported by this device.\n\nSensor events will be
delivered in continuous mode.
Do not show again