I have a very simple app which have a button and a label.
I initialize my sensor like below-
public void InitSensorService()
{
sManager = Android.App.Application.Context.GetSystemService(Context.SensorService) as SensorManager;
sManager.RegisterListener(this, sManager.GetDefaultSensor(SensorType.StepCounter), SensorDelay.Normal);
}
public void OnAccuracyChanged(Sensor sensor, [GeneratedEnum] SensorStatus accuracy)
{
Console.WriteLine("OnAccuracyChanged called");
}
public void OnSensorChanged(SensorEvent e)
{
if (running)
{
totalSteps = e.Values[0];
var currentSteps = Convert.ToInt32(totalSteps) - Convert.ToInt32(previousTotalSteps);
// It will show the current steps to the user
stepCounter = currentSteps;
}
}
But step counts are very very inaccurate...I tred with step counter ,step detector,even accelerometer with some logics...None of them gives accurate steps...As far accelerometer is closer,but step counter and step detector not working at all