我正在使用Google Firebase創建應用程序,並且我使用了他們提供給您的一些代碼,但我不知道這些變量中有幾個是什麼。變量是「auth_failed」和「EmailPasswordActivity」。這些變量應該是什麼? Firebase身份驗證使用電子郵件創建新帳戶
mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(this, new OnCompleteListener<AuthResult>()
{
@Override
public void onComplete(@NonNull Task<AuthResult> task)
{
Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());
// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
if (!task.isSuccessful())
{
Toast.makeText(EmailPasswordActivity.this, R.string.auth_failed, Toast.LENGTH_SHORT).show();
}
}
});
我很困惑什麼是上下文或如何使用/創建一個。 –
Android使用它來限制(本例中)Toast的生命週期。這不是Firebase特有的,所以我會在Android文檔中詳細閱讀一些關於它的文章,以獲得不融合和/或http://stackoverflow.com/questions/3572463/what-is-context-on-android。 –