First excuse me, my English is not my native language, I use the google translator.
This is my first extension, it is a pedometer that uses the device's step sensor (not the accelerometer) Sensor.TYPE_STEP_COUNTER
Not all devices have it, so there is a Boolean block that will tell us if the sensor exists in the device.
The sensor counts all the steps since the device is turned on and we start the sensor, if we restart the device the sensor will start with a value of 0
What the Start and Stop blocks do is start or stop the Listener to listen to the sensor and obtain the steps.
If the Listener is on, an event will occur that will return the steps performed so far (WalkStep)
In order not to lose data from the steps performed when the device is restarted in the .aia file, there is a procedure that solves this problem.
The pedometer works very well and the battery consumption is low, if you do not kill the application through the block or with the device's task cleaner, the pedometer continues counting steps even if it is asleep.
If you use the stop block it will also stop counting steps
SensorPedometer.aia (99.9 KB)
com.mariosoft.SensorPedometer.aix (8.4 KB)