I am creating a login page in android using Firebase Email Password Authentication and I want when a user enters its Email address and shift to password the system automatically get the PhotoUrl and DisplayName and display on the Login page Before a user enters His Full Password.
1
votes
1 Answers
0
votes
For do what you want one way is doing that:
So you have something like that in firebase database:
ASDEYRDSDDA
Email: [email protected]
Display_name: Jonh
Photo_URL: your_url
WERSWERSDFR
Email: [email protected]
Display_name: Maria
Photo_URL: maria_url
to get the data from firebase you only need to create a reference like that:
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("users");
and the listener:
myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot data: dataSnapshot.getChildren()){
String email=data.child("Email").getvalue(String.class);
if (email.equals("[email protected]")) {
//do ur stuff
String displayname=data.child("Display_name").getvalue(String.class);
String photourl=data.child("Photo_URL").getvalue(String.class);
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
So it checks in all childs if the data that you want exists and if yeas you do what you whant.