AndroidStepsManager to AndroidStepsCounter
We have migrated from the STEPS_COUNTER sensor to the STEPS_COUNTER sensor, and implemented various measures to
increase the steps service resilience, this will improve step count accuracy and fix discrepancy with popular apps
counter services like Google Fit.
However, this change introduced new requirements for the steps service, to avoid misunderstandings we decided to create
a new component AndroidStepsCounter that will eventually replace the now deprecated AndroidStepsManager in the next
major release.
Migration process
Requirements
To use AndroidStepsCounter you will need:
- Android permissions: Go to the main Android Permissions section to see the implementation.
- Alarms permissions (Optional): Go to the main Alarm permissions section to see the implementation.
AndroidStepsCounter uses the SCHEDULE_EXACT_ALARM permission to improve its lifetime in battery constrained
scenarios,
however this is optional, you can skip requesting this permission to your users and still use AndroidStepsCounter
normally. AndroidStepsCounter will only schedule an alarm if the permission is granted.
IMPORTANT: You need to call enableStepsCounter again after requesting the alarms' permission.
AndroidStepsCounter
Next you will find a mapping of each class/method to its corresponding replacement.
| Deprecated | Replacement |
|---|---|
AndroidStepsManager.isAvailable() | AndroidStepsCounter.isStepsCounterAvailable() |
AndroidStepsManager.isBackgroundAndroidStepsActive() | AndroidStepsCounter.isStepsCounterActive() |
AndroidStepsManager.enableBackgroundAndroidSteps() | AndroidStepsCounter.enableStepsCounter() |
AndroidStepsManager.disableBackgroundAndroidSteps() | AndroidStepsCounter.disableStepsCounter() |
AndroidStepsManager.syncTodayAndroidStepsCount() | AndroidStepsCounter.getTodayStepsCount() |