Google Fit API : Get distance from google fit

前端 未结 5 891
小鲜肉
小鲜肉 2021-01-28 17:35

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         


        
5条回答
  •  春和景丽
    2021-01-28 18:08

    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)
    

提交回复
热议问题