I'm having trouble with the FirebaseUI. The problem is, is that it starts the Email sign in flow at startup without clicking on anything. I want it to show the different sign in options, but it keeps starting the email sign in flow. I want it to show this:
But instead it goes directly into the email sign in flow whenever the app starts and without clicking anything. I never get the option to choose Facebook nor Google
This is my LoginActivty
public class LoginActivity extends AppCompatActivity {
private static final int MY_REQUEST_CODE = 7117;
private FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mAuth = FirebaseAuth.getInstance();
setContentView(R.layout.activity_login);
showSignInOptions();
}
@Override
protected void onStart() {
super.onStart();
FirebaseUser currentUser = mAuth.getCurrentUser();
if (currentUser != null) {
startActivity(new Intent(LoginActivity.this, MainActivity.class));
}
else {
Toast.makeText(this, "", Toast.LENGTH_SHORT).show();
}
}
public void showSignInOptions() {
AuthMethodPickerLayout loginLayout = new AuthMethodPickerLayout
.Builder(R.layout.activity_login)
.setEmailButtonId(R.id.email_button)
.setFacebookButtonId(R.id.facebook_button)
.setGoogleButtonId(R.id.google_button)
.build();
startActivityForResult(
AuthUI.getInstance().createSignInIntentBuilder()
.setTheme(R.style.AppTheme)
.setAuthMethodPickerLayout(loginLayout)
.build(), MY_REQUEST_CODE
);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == MY_REQUEST_CODE) {
IdpResponse response = IdpResponse.fromResultIntent(data);
if (resultCode == RESULT_OK) {
startActivity(new Intent(LoginActivity.this, MainActivity.class));
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
Toast.makeText(this, "Welcome " + user.getDisplayName(), Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(this, "" + response.getError().getMessage(), Toast.LENGTH_SHORT).show();
}
}
}
I don't see anywhere in my code that says it should start the emailflow. Please help me. Thanks in advance