我在登錄和註冊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
(用戶已註銷,因爲我無法註冊或登錄)。
我在我的清單中也有互聯網許可。