Signout Firebase

不打扰是莪最后的温柔 提交于 2019-12-11 15:51:44

问题


I'm doing a signout on my APP like this :

FirebaseAuth.getInstance().signOut();

The problem is that when I return to my Login Activity and I press again Sign in it does a re-login with the same account.

What I'd like to do is something like this :

Auth.GoogleSignInApi.signOut(mGoogleApliClient).setResultCallback(new ResultCallback<Status>() {
            @Override
            public void onResult(@NonNull Status status) {
                statusTextView.setText("Signed out");
            }
        });

If I do this (it's a button from Login Activity) it lets me log in with different account, but if I do only the FirebaseAuth.getInstance().signOut(); it does sign out, but if I do Login it re-log with the old email, is there any way to do this without having to create the mGoogleApiClient, etc..? I have to do this in differents Activities and I don't want to create it on each Activity, if I do it works I've tested it, but I think it's kinda dirty.


回答1:


I've faced the same issue and I solved it doing this

FirebaseAuth.getInstance().signOut();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        this.finishAffinity();
    }
    else{
        ActivityCompat.finishAffinity(this);
    }
    startActivity(new Intent(mContext,LoginActivity.class));

From the documentation

finishAffinity()

Finish this activity as well as all activities immediately below it in the current task that have the same affinity.



来源:https://stackoverflow.com/questions/48138882/signout-firebase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!