2017-02-09 36 views
-1

任何人都可以告訴我,當前用戶是做什麼的?Firebase getCurrentUser方法需要說明

private ProgressDialog progressDialog; 
private FirebaseAuth firebaseAuth; 
progressDialog = new ProgressDialog(this); 
    firebaseAuth = FirebaseAuth.getInstance(); 
    if (firebaseAuth.getCurrentUser() != null){ 
     //start profile activity 
     finish(); 
     startActivity(new Intent(getApplicationContext(),Profile.class)); 
    } 

我很困惑哪位用戶獲得當前用戶選擇?

回答

2

FirebaseAuth.getInstance()。getCurrentUser()返回firebase中當前登錄的用戶。從你的android模擬器獲取登錄憑據的用戶。如果用戶未登錄,getCurrentUser將返回null。

2

firebaseAuth.getCurrentUser()用於獲取FirebaseUser對象,其中包含有關登錄用戶的信息。 如果它返回null,用戶還沒有登錄,否則它將被重定向到Profile.class ...(在你的上面的代碼中)