I am building a tracking app that requires regular updates from the step counter. I have been working on this for a couple of months and have not faced any problems with the step counter so far. Now from one day to the next, the step counter is counting up to a certain number, then stops increasing the step number.
I am initializing the sensor from a foreground service like this:
float steps = 0;
mStepSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
mStepSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
mSensorManager.registerListener(this, mStepSensor, SensorManager.SENSOR_DELAY_NORMAL);
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
System.out.println("TrackingService/onSensorChanged", "Steps: " + sensorEvent.values[0]);
mSteps = sensorEvent.values[0];
}
After a reboot, the steps count up properly. Some time after a couple of thousand steps, the sensor just stops to emit any events. I haven't had that problem with exactly the same code in the past, but wanted to hear: Has anyone experienced a similar issue and can recommend a solution?