การยกเลิกการเชื่อมต่อจาก Google Fit จะเพิกถอนสิทธิ์ OAuth ทั้งหมดที่ได้รับอนุญาตสำหรับ แอปและลบการสมัครรับข้อมูลและการลงทะเบียนเซ็นเซอร์ทั้งหมดที่ทำขึ้นโดย แอปของคุณ
คุณต้องระบุตัวเลือกยกเลิกการเชื่อมต่อจาก Google Fit ให้กับผู้ใช้ในการตั้งค่าแอป เมื่อผู้ใช้เลือกตัวเลือกนี้ คุณจะเรียกใช้วิธีต่อไปนี้เพื่อปิดใช้ Google Fit ได้
ConfigClient.disableFit
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));