0

I want a specific user form firebase to access the activity with if statement by comparing current user ID with this ID = 47NiYA7rGNa8nJvlnnxzpxhqvCl2.

firebaseAuth = FirebaseAuth.getInstance();
FirebaseUser user = firebaseAuth.getCurrentUser();
String USER = user.getUid();
if (USER == "47NiYA7rGNa8nJvlnnxzpxhqvCl2"){
    finish();
    startActivity(new Intent(this, MainActivity.class));
}

But it does not work.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

0

I use this code and it works well with me.

firebaseAuth = FirebaseAuth.getInstance();
String currentUid = firebaseAuth.getCurrentUser().getUid();
if (currentUid == "47NiYA7rGNa8nJvlnnxzpxhqvCl2"){
    startActivity(new Intent(this, MainActivity.class));
    finish();
}

hope it helps you!

Amr Jyniat
  • 345
  • 5
  • 12