私のアプリケーションでは、初めてログインした後にユーザーをログインさせようとしています。これは動作していません。Android - ログインしているユーザーが動作していない(Firebase)
私のアプリケーションでは、複数のユーザータイプがあります。「学校」と「学生」です。私のアクティビティにはAuthStateListenerメソッドがありますが、私のアクティビティで何も起こりません。アプリケーションは、AuthStateListenerメソッドでコードを実行することなく、開始アクティビティに固執します。
mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
rootRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.child("usertype").getValue(String.class).equals("Students") && dataSnapshot.child("verified").getValue(boolean.class).equals(true)) {
Intent intent = new Intent(WaitingActivity.this, StudentsActivity.class);
startActivity(intent);
finish();
}
if (dataSnapshot.child("usertype").getValue(String.class).equals("School") && dataSnapshot.child("verified").getValue(boolean.class).equals(true)) {
Intent intent = new Intent(WaitingActivity.this, SchoolsActivity.class);
startActivity(intent);
finish();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
} else {
// User is signed out
Intent intent = new Intent(WaitingActivity.this, LoginActivity.class);
startActivity(intent);
}
// ...
}
};
私は何か間違っていますか?または私は何かを逃したか?
コールバックの最初の行にブレークポイントを設定すると( 'FirebaseUser user = firebaseAuth.getCurrentUser();')、トリガーされますか?また、あなたがエラーを無視しないようにしてください。 'public void onCancelled(DatabaseError databaseError){throw databaseError.toException(); } ' –