How do I calculate the distance covered by the user using the google fit API? Currently I am using google Fit History Api like this :
DataReadRequest readRequest
The answers are deprecated. With the newest api you do it like this:
Your request is fine however, you need those permissions mentioned above. You don't specify scope anymore tho.
Asking for connection:
val FITNESS_OPTIONS: FitnessOptions = FitnessOptions.builder()
.addDataType(//any other you might need)
.addDataType(DataType.AGGREGATE_DISTANCE_DELTA, FitnessOptions.ACCESS_READ)
.build()
GoogleSignIn.requestPermissions(
activity,
YOUR_INT_AUTH_CODE_FOR_ON_ACTIVITY_RESULT,
GoogleSignIn.getLastSignedInAccount(context),
GoogleFit.FITNESS_OPTIONS)