如何在GoogleFit SDK中退出Google身份验证? [英] How to sign out Google authentication in GoogleFit SDK?
本文介绍了如何在GoogleFit SDK中退出Google身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我检查用户帐户是否对Fitness API具有OAuth权限.
I check if user's account has OAuth permission to Fitness API.
private boolean hasOAuthPermission() {
FitnessOptions fitnessOptions = getFitnessSignInOptions();
return GoogleSignIn.hasPermissions(GoogleSignIn.getLastSignedInAccount(getActivity()), fitnessOptions);
}
然后,如果它返回false,则使用以下方法启动Google登录活动以请求用户的OAuth权限:
Then if it return false, launch the Google Sign In activity to request OAuth permission for the user by using this method:
private void requestOAuthPermission() {
FitnessOptions fitnessOptions = getFitnessSignInOptions();
GoogleSignIn.requestPermissions(
this,
REQUEST_OAUTH_REQUEST_CODE,
GoogleSignIn.getLastSignedInAccount(this),
fitnessOptions);
}
显示对话框以选择用户并允许权限.
It show dialog to choose user and allow permission.
如何注销Google登录,以再次显示帐户对话框?
How can I sign out Google Sign In, to able to show account dialog again?
推荐答案
如果您查看 Google Fit
您会发现您只需要这样做:
You would find that you just need to do:
Fitness.getConfigClient(this, GoogleSignIn.getLastSignedInAccount(this)).disableFit()
基本上,与点击与GoogleFit断开连接(从链接中引用)的行为相同
That is basically, same behaviour as tapping Disconnect from GoogleFit (Quote from the link)
这篇关于如何在GoogleFit SDK中退出Google身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文