與 Google Fit 取消連結後,系統會撤銷應用程式授予的所有 OAuth 權限,並移除應用程式產生的所有記錄訂閱項目和感應器註冊資料。
您必須在應用程式設定中提供「取消與 Google Fit 的連結」選項。使用者選取此選項時,您可以呼叫 ConfigClient.disableFit
方法來停用 Google Fit:
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));