Код: Выделить всё
String recentUserId;
// Code to get the user id's from the realtime database stored in keys
firebaseDatabase.getReference().child("Recent_Chats").child(auth.getUid()).get().addOnSuccessListener(new OnSuccessListener() {
@Override
public void onSuccess(DataSnapshot dataSnapshot) {
for (DataSnapshot snapshot1 : dataSnapshot.getChildren()) {
recentUserId = snapshot1.getKey();
Toast.makeText(getContext(), "hey therere" + recentUserId, Toast.LENGTH_SHORT).show();
}
}
});
// Code to get the relevant ids user data from Firestore
Query query = firebaseFirestore.collection("Users").whereEqualTo("uid", recentUserId);
query.get().addOnSuccessListener(new OnSuccessListener() {
@Override
public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
List list = queryDocumentSnapshots.getDocuments();
for (DocumentSnapshot d : list) {
User obj = d.toObject(User.class);
userArrayList.add(obj);
}
adapter.notifyDataSetChanged();
}
});
Я пробовал разные способы, но не смог получить ключи.>
Подробнее здесь: https://stackoverflow.com/questions/744 ... in-android
Мобильная версия