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