Search code examples
windows-runtimewindows-phone-8.1microsoft-band

Counting steps between sessions with Microsoft Band


I would like to use a subscription to the Pedometer to keep track of the number of steps the user has taken since my app last connected to the band. I was hoping there would be a way to read the number of steps taken today, like you can in the UI, but I haven't found a way to do that. The SDK says "On Windows and iOS, constant connectivity is required in order to maintain a subscription. If the band loses connectivity with the phone, the subscription is stopped and it is not automatically enabled upon reconnection." If I understand this correctly, it sounds like I can only measure the number of steps taken between bandClient.SensorManager.Pedometer.StartReadingsAsync() and bandClient.SensorManager.Pedometer.StopReadingsAsync() of a single connected session.

Is there a way to track the total steps a user has taken throughout the day using intermittent connections to the band through a background task?


Solution

  • My original answer was wrong. The Pedometer is returning the total number of steps since the last reset of the device. So, the steps will increment even if your app is not running. There is also no need to be connected to the band for this value to update. It is being stored and calculated on the band.

    So, an app could routinely pole the Pedometer sensor to retrieve the latest number of steps. Then a comparison between the current reading and the previous reading would provide the number of steps of the user has taken since your last pole event.

    So, you should be able to run your app in the background and periodically pole the Band for it's latest Pedometer reading.