I need to get the getUid of the connected user and set the id in an editText. I left below just to show what I want to do, because that way it does not work. How can I call a getUid connected in any part of the code and set it to EditText?
private EditText userId;
private FirebaseAuth.AuthStateListener minhaAuthListener;
userId = (EditText)findViewById(R.id.userId);
minhaAuthListener = new FirebaseAuth.AuthStateListener(){
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
Log.d("meuLog", "Usuário conectado: " + user.getUid());
userId.setText(user.getUid());
}
};