jackattack
jackattack

Reputation: 85

How to get a list of footsteps on android?

I'm developing an Android smartphone app and need to get a list of timestamps of all footsteps the user did in the last X minutes. As precise as possible. What I want looks something like this:

var timestampsOfStepsInLastXMinutesInMilisecs = listOf(1728290507599, 1728290507619, 1728290507637, ...)

What is the recommended way to achieve this?

I tought about just listening on Sensorevents from TYPE_STEP_DETECTOR, but this has two disadvanteges. Firstly, TYPE_STEP_DETECTOR isn't available on cheaper phones (but cheaper phones cheaper phones are able to count steps (via accelerometer?)). Secondly, reading sensors, when app goes to background / phone gets locked seems to be not that easy (How to get sensor data in service when screen is turned off?, Android: Is there any way to collect data from the Significant Motion sensor when the app is in the background?, ...).

My second idea was to use google fit, but it is deprecated.

My last idea is to use Health Connect, but at the moment I don't understand the documentation well enough. Do I really only get a step count delta over a period of time and not the timestamps of steps? (Then it would be useless for me)

There are so many pedometer apps out there, the topic can't actually be that complicated, right?

Upvotes: 0

Views: 62

Answers (0)

Related Questions