Please check code below: `
make structure something like: (it may vary as per your need I am just referring something to you)

I have an object "isTyping" with Two Keys Let's say "first_user" and "second_user".
If you want to check for "second_user" is typing or not this should be the code.
private void checkForOtherUserTypingStatus() {
mMessageThread.child("isTyping").addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
if (dataSnapshot.getKey().equalsIgnoreCase("second_user") && dataSnapshot.getValue().toString().equals("true")) {
updateTypingViewVisibility(true);
} else if (dataSnapshot.getKey().equalsIgnoreCase("second_user") && dataSnapshot.getValue().toString().equals("false")) {
updateTypingViewVisibility(false);
}
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
if (dataSnapshot.getValue() != null) {
if (dataSnapshot.getKey().equalsIgnoreCase("second_user") && dataSnapshot.getValue().toString().equals("true")) {
updateTypingViewVisibility(true);
} else if (dataSnapshot.getKey().equalsIgnoreCase("second_user") && dataSnapshot.getValue().toString().equals("false")) {
updateTypingViewVisibility(false);
}
}
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
To update value of "isTyping" > "first_user" (assume that you are typing)
mBinder.etChatMessage.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
Map<String, Object> params = new HashMap<>();
params.put("first_user", charSequence.length() > 0);
mMessageThread.child("isTyping").updateChildren(params);
}
@Override
public void afterTextChanged(Editable editable) {
}
});