我完全按照说明进行操作,事实上,我什至使用了 Android Studio 中 Firebase 帮助程序中的代码。我的问题就是这样,我的代码也没有发生登录或登录失败!我错过了什么?
public void toSubscribe(View v) {
Log.d("OK", "this part first");
String strUsername, strPassword;
strUsername = ((EditText) findViewById(R.id.username)).getText().toString();
strPassword = ((EditText) findViewById(R.id.password)).getText().toString();
if (strUsername.matches("")) {
Toast.makeText(MainActivity.this, "You did not enter a username.", Toast.LENGTH_SHORT).show();
return;
}
if (strPassword.matches("")) {
Toast.makeText(MainActivity.this, "You did not enter a password.", Toast.LENGTH_SHORT).show();
return;
}
mAuth.signInWithEmailAndPassword(strUsername, strPassword)
.addOnCompleteListener(MainActivity.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d("TAG", "signInWithEmail: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()) {
Log.w("TAG", "signInWithEmail", task.getException());
Toast.makeText(MainActivity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
}
});
}
没什么可说的...我尝试使用新的 JSON 文件,但它仍然不起作用。我在 Google 上搜索了很多东西,但没有任何效果。
最佳答案
请检查以下内容:
1-您从 firebase 控制台正确安装并添加 Gson 文件
2-您从 Firebase 控制台启用 Firebase 身份验证
3-您的mAuth
已正确初始化
关于java - Firebase 未触发成功或失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51993578/