我在登录和注册Firebase事件时遇到问题。代码跳过整个事件。Firebase电子邮件+密码登录事件未触发
public class LoginFragment extends Fragment {
String TAG = "LOGIN";
TextView tvLoginError;
EditText etUsername, etPassword;
Button btnLogin;
public LoginFragment() {}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.login, container, false);
setupTools(rootView);
return rootView;
}
private void setupTools(View rootView){
tvLoginError = (TextView) rootView.findViewById(R.id.tvLoginError);
etUsername = (EditText) rootView.findViewById(R.id.etUsername);
etPassword = (EditText) rootView.findViewById(R.id.etPassword);
btnLogin = (Button) rootView.findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final String username = etUsername.getText().toString();
final String password = etPassword.getText().toString();
// login
Authenticate.mAuth.signInWithEmailAndPassword(username, password).addOnCompleteListener(getActivity(), 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());
tvLoginError.setText("Login failed - " + task.getException().getMessage().toString());
}
}
});
}
});
}
}
Authenticate.mAuth不为空。用户名和密码已设置。
没有错误,它只是完全跳过signInWithEmailAndPassword
中的onComplete
函数。我的AuthStateListener
事件Authentication
被触发onResume
在Authentication
(用户已注销,因为我无法注册或登录)。
我在我的清单中也有互联网许可。