I have activity in android project but when activity start i have node in firebase it should be online but its not working? : if i minimize my app and run that activity it works but when i come to that activity from another activity its not working

in my onCreate like below

    auth = FirebaseAuth.getInstance();
            currentUser = auth.getCurrentUser();
    
            db = FirebaseDatabase.getInstance();
            userRef = db.getReference().child("Users").child(auth.getCurrentUser().getUid());
    
            if(currentUser == null) {
                sendToStart();
            } else {
                userRef.child("online").setValue("true");
            }

I have the same thing in my onStart method too but not working
can you please help me 


 
