Display the login user name by registered email and password in firebase in the app

Asked

Viewed 2,297 times

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: inserir a descrição da imagem aqui

Can someone give me a hand?

1 answer

0

  • 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.

  • 1

    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);

  • Okay, my friend! Thanks for your help. I managed to resolve.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.