Firebase: How to keep an Android user logged in?

前端 未结 4 1667
猫巷女王i
猫巷女王i 2021-02-05 11:53

I\'m using Firebase SimpleLogin to enable Email / Password authentication. Creation of users and subsequent login is all working fine. However, whenever I leave the app (even if

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-05 12:38

    You can do this by Using this Approach to escape logi page if User already logged in.

    private FirebaseAuth auth;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        auth = FirebaseAuth.getInstance();
    
        if (auth.getCurrentUser() != null) {
            startActivity(new Intent(Login_Activity.this, Home.class));
            finish();
        }
        setContentView(R.layout.activity_login_);
    

提交回复
热议问题