I've setup app that connects to Google Fit, reads and writes some data about users body. When user disables Google Fit in apps settings, I try to revoke my apps permissions for by calling:
public void disableGoogleFit(){
if(!mClient.isConnected()){
Log.e(TAG, "Google Fit wasn't connected");
return;
}
PendingResult<Status> pendingResult = Fitness.ConfigApi.disableFit(mClient);
pendingResult.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
if(status.isSuccess()) {
Log.i(TAG, "Google Fit disabled");
}else{
Log.e(TAG, "Google Fit wasn't disabled " + status);
}
}
});
}
Even though I could successfully read/write data, disabling Fit returns me error:
Google Fit wasn't disabled Status
{statusCode=unknown status code: 5010, resolution=null}
Edit1: Added whole method, in which its visible, that client is connected at the moment I try do disable Fit.
Delete your Google Fit dataAt the bottom, tap Profile. Tap Manage your data. "Delete All." Confirm you want to delete the data.
Currently with 15.0.1 lib it can be easily done:
fun disconnect(context: Context) {
val fitnessOptions = FitnessOptions.builder()
.addDataType(DataType.TYPE_WORKOUT_EXERCISE, FitnessOptions.ACCESS_READ)
.build()
val signInOptions = GoogleSignInOptions.Builder().addExtension(fitnessOptions).build()
val client = GoogleSignIn.getClient(context, signInOptions)
client.revokeAccess()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With