尝试从Firebase Auth和Google登出 [英] Trying to sign out from Firebase Auth and Google
问题描述
所以,我的问题是,当我从Firebase中注销时,按登录后无法再次弹出带有不同帐户的登录窗口
So, my problem is that when i log out from firebase i cant see the log in window with the different accounts pop up again after i press login
所以我发现我们需要从google api中注销,这是我的代码,但我遇到了错误
So i found that we need to logout from google api, here is my code how i do it but i get an error
这在我的按钮 onClick
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
FirebaseAuth.getInstance().signOut();
finish();
}
});
我得到这个错误
'android.content.Contextcom.google.android.gms.common.api.GoogleApiClient.getContext()'空对象引用
'android.content.Context com.google.android.gms.common.api.GoogleApiClient.getContext()' on a null object reference
在此行
Auth.GoogleSignInApi.signOut(mGoogleApiClient).......
知道发生了什么吗?
推荐答案
首先使用 mGoogleApiClient.connect();
,然后只需检查 Auth.GoogleSignInApi
是否无效:
First use mGoogleApiClient.connect();
and then just check Auth.GoogleSignInApi
for nullity:
if (Auth.GoogleSignInApi != null) {
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
FirebaseAuth.getInstance().signOut();
finish();
}
});
}
这篇关于尝试从Firebase Auth和Google登出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!