解除与 Google 健身的关联

取消与 Google 健身的关联会撤消所有已授予您的应用的 OAuth 权限,并移除您的应用进行的所有记录订阅和传感器注册。

您需要在应用设置中提供取消与 Google 健身的关联选项。当用户选择此选项时,您可以调用 ConfigClient.disableFit 方法来停用 Google 健身:

Kotlin

Fitness.getConfigClient(this,  GoogleSignIn.getAccountForExtension(this, fitnessOptions))
    .disableFit()
    .addOnSuccessListener {
        Log.i(TAG,"Disabled Google Fit")
    }
    .addOnFailureListener { e ->
        Log.w(TAG,"There was an error disabling Google Fit", e)
    }

Java

Fitness.getConfigClient(this, GoogleSignIn.getAccountForExtension(this, fitnessOptions))
        .disableFit()
        .addOnSuccessListener(unused ->
            Log.i(TAG, "Disabled Google Fit"))
        .addOnFailureListener(e ->
            Log.w(TAG, "There was an error disabling Google Fit", e));