Java if语句检查数据库信息,在';这是不应该的

Java if语句检查数据库信息,在';这是不应该的,java,android,firebase,firebase-authentication,Java,Android,Firebase,Firebase Authentication,我正在尝试执行一个错误检查登录活动,如果它检测到以下问题,它将触发一个意图: 1) 如果用户还没有注册(他使用的电子邮件没有通过firebase验证),这对我来说很好 2) 如果用户已注册但未向firebase数据库提供任何信息 我的问题是,出于某种原因,我用来检查数据库中信息的代码适用于用户,即使他们的UID中附带了数据库中的信息 也就是说,当他们已经提供了信息时,就会触发告诉他们提供信息的意图 if(task.isSuccessful()){ // Checks if user ha

我正在尝试执行一个错误检查登录活动,如果它检测到以下问题,它将触发一个意图:

1) 如果用户还没有注册(他使用的电子邮件没有通过firebase验证),这对我来说很好

2) 如果用户已注册但未向firebase数据库提供任何信息

我的问题是,出于某种原因,我用来检查数据库中信息的代码适用于用户,即使他们的UID中附带了数据库中的信息

也就是说,当他们已经提供了信息时,就会触发告诉他们提供信息的意图

if(task.isSuccessful()){
    // Checks if user has submitted information in the Essential Information activity
    //Takes the Unique ID(if it is present if not it will tell him to sign up or invalid email) asks the firebase database if he has given information to the database
    reference.child("Users").child(UserUID).addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            // User exists
            if (dataSnapshot.exists()) {
                //Displays Toast telling user that their information is saved in the database
                Toast.makeText(LogInActivity.this, "You have data in our database ", Toast.LENGTH_SHORT).show();
            }
            //User doesn't have information in the database
            else {
                // Displays Toast telling user he/she needs to sign in into the firebase database
                // User goes to UserInformationActivity to give his/her information
                Toast.makeText(LogInActivity.this, "You need to give Essential Information", Toast.LENGTH_SHORT).show();

                // 3 second delay
                final Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        // Goes to UserInformationActivity
                        Intent GoToUserInformation = new Intent(LogInActivity.this, UserInformationActivity.class);
                        LogInActivity.this.startActivity(GoToUserInformation);
                    }
                }, 3000);

            }


        }
        // if the checking got cancelled, likability of that happening is small
        @Override
        public void onCancelled(DatabaseError databaseError) {

        }

    });
}

是否要检查用户是否已登录

直接从firebase

FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
    // User is signed in
    // check a snapshot to see if there is information....if not, error out.
} else {
    // No user is signed in
}

对于那些可能不理解我的意思的人,我的意思是,数据库中有信息的用户将被带到数据库中再次提供所述信息。您不需要
处理程序来创建意图并启动新的Activity@Chisko是的,没错,
Handler
延迟3秒,用户可以读取
Toast
读取的内容。Toast将在屏幕上显示Toast.short或Toast.long。。。你不需要一个处理程序。除非到了隐藏的时候,否则土司会留下来。@Droidv删除了Handler,同样的问题仍然存在,Handler不是问题所在