0
Hi, I need your help, because I’ve looked at it in a lot of ways, and I can’t fix it. I am wanting to display the name of the user logged in to the application by Firebase. NO Edititext the return is this line with link to firebase (.firebaseio.com/usuario/9FrkXtxNuDW97HI0JtrGufquIxQ2/email).
I’m using the following code on Activity:
final String user_id = mAuth.getCurrentUser().getUid();
mDatabase = FirebaseDatabase.getInstance().getReference().child("usuario").child(user_id).child("email");
mEditText.setText(mDatabase.toString());
It works, but it only displays that url. What’s missing there. The User enters the application with the Firebase email login/password, and goes to Mainactivity, where I run this command to display the name. But it doesn’t look like the name that’s registered to Firebase:
Can someone give me a hand?
Good morning, Allef Sousa. I did as you indicated, but I noticed that it is displaying a new user, not the user who was logged in to the app entry, with the login screen. the id of the user is: "Zxzlcmxhbmlvqghvdg1hawwuy29t". But when you enter main Activity the user id that is displayed is this: "9FrkXtxNuDW97HI0JtrGufquIxQ2". That’s why he returns null. How can I make the logged in user the same as the login.
– Everlanio Paulo
I did it like this, I don’t know if it’s correct but the one that solved for me. I only save the data in the firebase after the user logs in. User logs in to an Activity , it is directed to the main Activity of the project where I check if it is logged in msm. If you are saved in the Realtime Database. if (mAuth.getCurrentUser() != null) { keyUser = mAuth.getCurrentUser(). getUid();
 userLogado.setIdUsuario(mAuth.getCurrentUser(). getUid()); dataUser.child(keyUsuarioLogado). setValue(userLog);
– Allef Sousa
Okay, my friend! Thanks for your help. I managed to resolve.
– Everlanio Paulo