1 回答
TA贡献1829条经验 获得超7个赞
您已在问题中描述了此问题的原因。因此,解决此问题的一种方法如下-
databaseReference = firebaseDatabase.getReference("Users/" + firebaseAuth.getInstance().getCurrentUser().getUid());
databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
user.setProfileComplete(dataSnapshot.getValue(User.class).getProfileComplete());
//The profileComplete method returns TRUE, so we can skip the profile creation.
if(user.getProfileComplete()) {
Intent intent = new Intent(MainActivity.this, ViewProfileActivity.class);
startActivity(intent);
}
//the profileComplete method returns FALSE, we must send the user to the profile creation.
else {
Intent intent = new Intent(MainActivity.this, ProfileActivity.class);
startActivity(intent);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Log.d("MainActivity", "COULD NOT RECIEVE PROFILECOMPLETE FROM DATABASE");
}
});
添加回答
举报