0

Version:

implementation "com.google.android.gms:play-services-fitness:21.1.0"

Client definition:

GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .requestScopes(Scope("https://www.googleapis.com/auth/fitness.activity.read"), Scope("https://www.googleapis.com/auth/fitness.location.read"))
            .requestIdToken(BuildConfig.GOOGLE_FIT_CLIENT_ID)
            .requestServerAuthCode(BuildConfig.GOOGLE_FIT_CLIENT_ID, true)
            .build()

val readRequest = DataReadRequest.Builder()
                .read(DataType.TYPE_ACTIVITY_SEGMENT)
                .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
                .build()

This gives me the list of dataSets -> dataPoints -> biking activities but no data about the distance. Only start/end time and the activity type.

If I open same activity in Google Fit app, it shows the distance of same activities. Any ideas?

1 Answer 1

1

After you parse activity and location, you need to parse distance delta in a separate query.

This data type captures distance travelled by the user since the last reading, in meters. The total distance over an interval can be calculated by adding together all the values during the interval. The start time of each data point should represent the start of the interval in which the distance was covered. The start time must be equal to or greater than the end time of the previous data point.

https://developers.google.com/fit/datatypes/location#android_2 https://developers.google.com/fit/datatypes/location#distance_delta

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, though I had no chance to test it since we migrated to health connect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.