0

I have written the code to count the number of steps implementing the SensorListener class. But the problem is that onSensorChanged method is called after certain number of steps. It seems that it has to verify that these calls are as a result of walking and not phone shake. But I need to skip this delay and start counting steps as soon as the user starts walking. Because the accuracy of the amount of steps matters a lot. How can I achieve this? I do not want to use accelerometer though. That seems less accurate compared to the step counter sensor readings. Any help would be much appreciated.

AnOldSoul
  • 4,017
  • 12
  • 57
  • 118

1 Answers1

1

I think you are using Step Counter sensor. If you use Step Detector sensor instead you can track steps even when your app is not up. Step Detector sensor gives the number of steps since last device boot, so you can make relative calculations between different readings. If you concern is to get the exact number of steps this is your sensor.

lorenzohm
  • 21
  • 3
  • Actually the problem I'm facing is that both the step detector and step counter sensors wait for a little time before they start to give the step count values. They do this in order to verify that the steps count occurred because of actual walking. According to the docs, "algorithm does more processing to eliminate false positives". What I need is to skip this processing. I don't mind false positives but the sensor has to give values as soon as the user starts walking. – AnOldSoul Oct 12 '16 at 09:47