【问题标题】:Trying to sign out from Firebase Auth and Google尝试从 Firebase Auth 和 Google 退出
【发布时间】:2017-12-12 14:39:35
【问题描述】:

所以,我的问题是,当我从 firebase 注销时,我无法看到登录窗口,在我按下登录后再次弹出不同的帐户

所以我发现我们需要从 google api 注销,这是我的代码,但我得到了一个错误

这是在我的按钮内onClick

 Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(new ResultCallback<Status>() {
                             @Override
                             public void onResult(@NonNull Status status) {
                                 FirebaseAuth.getInstance().signOut();
                                 finish();
                             }
                         });

我得到了这个错误

'android.content.Context com.google.android.gms.common.api.GoogleApiClient.getContext()' 空对象引用

在这一行

 Auth.GoogleSignInApi.signOut(mGoogleApiClient).......

知道发生了什么吗?

【问题讨论】:

    标签: android firebase firebase-authentication


    【解决方案1】:

    首先使用mGoogleApiClient.connect();,然后检查Auth.GoogleSignInApi 是否为空:

    if (Auth.GoogleSignInApi != null) {
        Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(new ResultCallback<Status>() {
             @Override
             public void onResult(@NonNull Status status) {
                 FirebaseAuth.getInstance().signOut();
                 finish();
             }
         });
    }
    

    【讨论】:

    • 问题是我需要启动 mGoogleApiClient.connect();在我的 onstart 方法中
    猜你喜欢
    • 2018-11-16
    • 2021-11-28
    • 1970-01-01
    • 2017-08-08
    • 2022-06-20
    • 2021-05-14
    • 2016-11-06
    • 2019-02-10
    相关资源
    最近更新 更多